Compare commits

...

70 Commits
next ... v3.2.7

Author SHA1 Message Date
Mike Hansen
fb10d141d0 Merge pull request #18 from Telecominfraproject/OLS-563-version-client-tag-and-update-schema-ref
[OLS-563] Add version to ols-ucentral-client
2025-02-03 09:27:55 -05:00
Mike Hansen
176d2b9f36 [OLS-563] Add version to ols-ucentral-client
Dockerfile updated to pull tagged version of schema to get the schema.json file.
This will make subsequent versioning much easier.

Once this is merged we can tag the client as 3.2.7 and then move forward to 4.x as we did with the schema.

Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
2025-01-31 16:48:09 -05:00
Mike Hansen
41d50f4650 Merge pull request #17 from Telecominfraproject/OLS-563-Add-version-to-ols-ucentral-client
[OLS-563] Add version to ols-ucentral-client
2025-01-27 09:36:05 -05:00
Mike Hansen
00ae4001e7 [OLS-563] Add version to ols-ucentral-client
Add version to ols-ucentral-client
Augment the build to pull the schema version file from the ols-ucentral-schema repo (if present) based on commit id of
schema used as baseline for this client version.
Use both it and the version to provide the version information in the connect message.

Signed-off-by: Mike Hansen <mike.hansen@netexperience.com>
2025-01-22 19:49:46 -05:00
Olexandr, Mazur
5936fbed88 Merge pull request #13 from r4nx/fix-cpp-compilation
Fix compilation issue when platform is implemented in C++
2024-05-14 23:24:10 +03:00
Viacheslav Holovetskyi
0aea2e273c Fix compilation issues
new is a C++ keyword, so the header couldn't be used from C++
2024-04-29 16:17:53 +03:00
Olexandr, Mazur
6e8ccbf40c Merge pull request #12 from Telecominfraproject/plv_next/2.2_build5
Plv next/2.2 build5
2024-04-16 18:53:14 +03:00
Oleksandr Mazur
80f01f977c Update build version to 2.2 b5
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I8ba40d21d4f1d4c81eee906fce0bae6b76aa6052
2024-04-16 17:53:25 +03:00
Oleksandr Mazur
145f8aba82 Fixup scripts: make sure uplink iface (port) is dhcp trusted
With the DHCP-snooping full support for the BRCM platforms
it's needed for the ports to be marked either trusted/untrusted
to make sure proper DHCP request/reply forwarding occurs.

With this commit the following behavior is enforced:
 * Every port is untrusted by default upon device startup;
 * Uplink interface (port) is determined through the means of
   parsing ARP+FBD table;
 * DHCP trust is enabled only for the uplink port;
 * All vlan members can now send DHCP discover(s), which
   will be forwarded (flooded) to trusted ports (in our
   case to a single trusted uplink port) and get
   their replies back.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
2024-04-16 16:30:01 +03:00
Olexandr, Mazur
e53d618a33 Merge pull request #11 from Telecominfraproject/plv_next/2.2_build4
Plv next/2.2 build4
2024-04-08 14:39:14 +03:00
Oleksandr Mazur
0799cec723 Update build version to 2.2 b4
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: Id96cba2b6e1e53a0706133492172c17f860bb2f3
2024-04-08 14:18:08 +03:00
Oleksandr Mazur
24143fc5bc Fix infinite loop deviceupdate send
Deviceupdate condition never fails whenever password is changed,
thus makes the device spam with passwordchange events.
This, as a results, overflows internal buffers, which
overflows internal disk storage.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
2024-04-08 13:56:11 +03:00
Oleksandr Mazur
15b9868322 Revert "script: Use a new GW address"
This reverts commit 4911cab05e.
2024-04-08 13:37:10 +03:00
Olexandr, Mazur
54141e0af6 Merge pull request #10 from Telecominfraproject/plv_next/2.2_build3
Plv next/2.2 build3
2024-04-07 12:30:13 +03:00
Oleksandr Mazur
9034123c2e Update build version to 2.2 b3
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I2d6837667e39be364e32a4a73932928b1edd6b0a
2024-04-07 12:28:45 +03:00
Serhiy Boiko
d0189eaad6 plat: ipv4: Skip L3 configuration for default vlan
Do not apply or modify any L3 cfg for Vlan 1 (ip, dhcp, igmp, etc.)

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I0e19bad017cacc14cb30af946101d7ad4d9bc8d0
2024-04-07 12:28:38 +03:00
Serhiy Boiko
c349f3f9a4 proto: log: Remove unused code
'log' field is expected to be (and is defined in the schema as) an object,
so there is no need to handle it as an array.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I05dd8de1fad086fd6ea16a4cb4792ad7f6e826fd
2024-04-07 12:28:27 +03:00
Serhiy Boiko
5832ecdf36 cfg: Align config samples with current schema definitions
Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I7b4a2974d19ea645c7cfe7ab9ca1bde27a849f73
2024-04-07 12:28:19 +03:00
Serhiy Boiko
4911cab05e script: Use a new GW address
Use docker env variables to pass a new gw addr, since the old
gw (that is reported by the redirector) is not available.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ibb3a3b95d556996617d7f4ce1d6a58303df76ad7
2024-04-07 12:28:09 +03:00
Serhiy Boiko
7442bb79c3 ucentral-client: Fix env variable for GW address
Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I811f4faeb438d84e6cbd88905c9bb5846264ef5a
2024-04-07 12:27:58 +03:00
Serhiy Boiko
f972987312 proto: Fix RPVSTP config being rejected
'priority' should be a multiple of 4096

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ie974257c47be54852d8a634022ad6f033f06597a
2024-04-07 12:27:48 +03:00
Olexandr, Mazur
783368dd7b Merge pull request #9 from Telecominfraproject/feat/igmp_global_querier_filtering
plat: Parse new fields from config message
2024-04-02 13:00:06 +03:00
Serhiy Boiko
dc60bab84b plat: Parse new fields from config message
Parse and handle unknown-multicast-flood-control and querier-enable fields.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ifa0620bc22e3235b8fb4eb2f7f5dcd026ad0404f
2024-04-02 12:46:39 +03:00
Olexandr, Mazur
681efcabfc Merge pull request #8 from Telecominfraproject/plv_next/next_290324
Plv next/next 290324
2024-03-29 17:34:25 +02:00
Oleksandr Mazur
6f6bd4dfd0 Update build version to 2.2 b2
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I1091f1f34d38f197bdc272adab018a2ec68b5bbf
2024-03-29 17:31:04 +02:00
Serhiy Boiko
04e80e1650 proto: Move diagnostics to a separate thread
Running diagnostics takes a long time (up to 10mins). Running
it in the same context as the callback broker means that all
messages are blocked until diagnostics is finished.
Creating a new thread resolves this issue.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Iadb628007903a7d643b6d2e705da84fd04e73dbe
2024-03-29 17:27:58 +02:00
Serhiy Boiko
a8e2b18733 plat: Report uplink address in state message
Reported info:
- uplink ip addr
- mac addr
- egress port
- route metrics

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ifdae793be73f4c43b3daffb4cf3f4016ea989d44
2024-03-29 17:27:53 +02:00
Oleksandr Mazur
2e5499c375 Fix DHCP + NTP not working properly for Vlan1
Enable properly DHCP snooping for Vlan1 by default;
Make sure NTP is configured to use Vlan1 as wel;

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: Ided132b12a5d472954458632cd61b3e43e072fa0
2024-03-29 17:27:48 +02:00
Serhiy Boiko
0f64807cfb port-isolation: Update parser based on schema
Since port isolation schema moved from ethernet to switch update
the code acordingly.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I30335af3d17ad6ecc910c5c8ed2ca69eaaae0913
2024-03-29 17:27:41 +02:00
Serhiy Boiko
215d4dab4a vlan: Add SVI ip addrs to state message
Add netlink calls to get vlan ip addrs.
Add gnma api to retreive list of addrs.
Add "addresses" field to vlan interfaces.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I4a43485d45c75993ef128c952acfd69f04cd975e
2024-03-29 17:27:35 +02:00
Olexandr, Mazur
e13a8fac52 Merge pull request #7 from Telecominfraproject/plv_next/next_040324
Plv next/next 040324
2024-03-04 16:53:19 +02:00
Serhiy Boiko
049fef08d9 ipv4: Fix interface ipv4 cfg parsing
The schema requires the config to have the following format:
  {
    "ipv4": {
      "subnet": [
        { "prefix": "255.255.225.255/32" }
      ]
    }
  }

But the code expected this:
  {
    "ipv4": {
      "subnet": "255.255.225.255/32"
    }
  }

Since parsing ipv4 for vlans and ports is the same the code
is moved to a function.
*_interface_parse function were refactored to remove unnecessary
indentations.

Limitations:
Only a single ip address can be configured on an interface.
IP address will be configured only for the first port in the list.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ie3ed777a963129269b10833c970dc3e8a24b6b38
2024-03-04 16:50:18 +02:00
Serhiy Boiko
2bd145e09f cfg: Beautify json configs
Use https://codebeautify.org/jsonviewer to beautify all configs.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I4e82ae96927d4f63027c68f17d2179adb9f09052
2024-03-04 16:50:18 +02:00
Serhiy Boiko
732b4e1bc7 cfg: Add sample configs for new and old features
Sample configs added:
- log service
- port isolation
- igmp
- stp

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ia58fab2da04658100b5be1044892f4966d935e10
2024-03-04 16:50:18 +02:00
Serhiy Boiko
559776ba06 proto: Fix parser issue
WA for issue where an array of objects might have malformed keys:

Original message:
    {
        "static-mcast-groups": [
            {"address": "1.1.1.1",
             "egress-ports": [...]}
        ]
    }

Malformed message:
    {
        "static-mcast-groups": [
            {"static-mcast-groups[].address": "1.1.1.1",
             "static-mcast-groups[].egress-ports": [...]}
        ]
    }

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Id0ebe93ab976338adab6cdc3b7d6691ecca9dc94
2024-03-04 16:50:18 +02:00
tip-admin
b6c03319d3 Create LICENSE 2024-02-29 08:52:04 -08:00
Olexandr, Mazur
05d06592cc Merge pull request #5 from Telecominfraproject/plv_next_270224
Plv next 270224
2024-02-27 14:35:52 +02:00
Serhiy Boiko
ebf160fa06 igmp: Fix invalid port name size
sizeof(*port_node->name) == 1
sizeof(port_node->name) == PORT_MAX_NAME_LEN  # 32

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I3bd09eaf00bb55045a935de7795509f5582b0878
2024-02-27 14:04:18 +02:00
Serhiy Boiko
ace64ef341 stp: Fix STP config not applying
Fix issue where STP config was rejected on device because
some of the GNMI entries could not be deleted.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ida30be22c609c682b526358c98225bff0567290c
2024-02-27 14:04:16 +02:00
Serhiy Boiko
5acd35237c igmp: Change what attributes are set for snooping/querrier
Set querrier attributes only for `ip igmp ...`.
Set snooping attributes only for `ip igmp snooping ...`

fixes: a15c56f
Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I56369d323fdd8b2b63605392cb8b23fa0442bb8a
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
d9fae8097b Update build number 1.6 b5
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I63b7b8b9945ed67f6ddba104ec3c154c63a308dc
2024-02-27 14:04:12 +02:00
Serhiy Boiko
ee4ff0ee3a igmp: Configure igmp snooping and static groups
Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I679807532d04338077cc8657ed9702d3ad09536e
2024-02-27 14:04:12 +02:00
Serhiy Boiko
6efdcb7eb5 igmp: plat: Fill vlan interface data
Store IGMP info inside plat struct (GNMI/GNMA handlers);
Add vlan interfaces to the list of all interfaces (proto handlers).
Vlan interfaces have a multicast field as per state schema.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Id9778a017e0ba54f8e1154e580304f95e3de41c8
2024-02-27 14:04:12 +02:00
Serhiy Boiko
bca8160f67 sfp: Send transceiver info to GW
Notify GW about the ports' transceiver info. If transceiver
info is not supported the "transceiver-info" field is omitted.

    "interfaces": [
        ...
        {
            ...
            "transceiver-info": {
                "vendor-name": "VENDOR",
                "part-number": "PART NUMBER",
                "serial-number": "SERIAL",
                "revision": "REVISION",
                "temperature": 0,
                "tx-optical-power": 0,
                "rx-optical-power": 0,
                "max-module-power": 0,
                "form-factor": "FORM FACTOR",
                "supported-link-modes": [ ... ]}
            ...
        },
        ...
    ],

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: If83bb41d1ebf76b41c2ed0be6f3f755eefa18d29
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
3d2b3295e7 proto: fill state with CoA-related global counters
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I0979c0abf180fe5a8309fc43ed233352edda936c
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
15e4f7a580 gnma: Implement gnmi handlers for fetching COA stats
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: If5027dbb59522731312941b4e539f38e8a54dc70
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
1afbc126fe gnma: implement DAS + DAC gnmi handlers + plat_state recovery
Implement handlers for retrieving platstate of DAS configuration,
as well as DAC list (same as for RADIUS clients).

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: Ifa149aa1708c114cc4b5b59772d524f4cd5b70b2
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
a2c49e8ab5 gnma: remove unused radius host definition
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I3cb4739bd6f0724dad784caf381e9f7f01797153
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
2a8d2c18ce gnma: fix invalid poe stats reported
Newest BRCM images changed from number->string values of
some PoE-related info.
Fix parsing to report valid data back to cloud.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I46afee603f16439fa23adda698be748bfe008b04
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
4549ef61c3 proto: fix FSM for plat diagnostics
GW expects for reply to be sent immediatly (pending state).
This gives GW understanding that command's been processed,
but is still executing.
The final result would be sent afterwards, upon diag completion.
However, the initial pending should be sent as fast as possible,
upon parsing the command itself.

This change fixes the expectations of GW. Without this change
command is marked as timedout, then pending and the completed
OK.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I36925783fc2bc1cd7dfebb957d7ba30d2c7650ea
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
5710119746 proto: remove iface-type from port isolation
Schema changes pruned the type from port-isolation definition.
Aling basecode with schema requirements.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I985022fdefda25461734e8158df7464220f84d8b
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
cedf998260 gnma/proto: fix issues introduced with port-isolation support
- crash upon clearing port-isolation
- memleak of never-freed port-isolation cfg

Change-Id: I847708249cf85f2cfd40ebffefbd56cee822ea8d
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
963120f2b4 proto: implement port-isolation pasring
Only partial - json parsing - implementation is present.
Parsed (from JSON) config values can be used
in Platform code, upon applying conf, to alter port-isolation cfg.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I5deb31be5b5b2295a7698ca357fc10555b5dd772
2024-02-27 14:04:12 +02:00
Oleksandr Mazur
8b4a63fb66 proto: implement services (ssh, http, telnet) pasring
Implement partial (only enable/disable) parsing of services - common part
of OLS-NOS repo.
Only partial - json parsing - implementation is present.
Parsed (from JSON) config values (bool - enable true/false) can be used
in Platform code, upon applying conf, to alter services state.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I2c25724913b5524729950513fd6c5f3b1c25f9e0
2024-02-27 14:04:12 +02:00
Olexandr, Mazur
60abb9a7e6 Merge pull request #1 from Telecominfraproject/plv_next
Plv next
2024-01-22 20:29:41 +02:00
Serhiy Boiko
0b683379b4 system-password: Allow to change admin pass from GW
System (admin) password is changed every time the configure
message contains a system-password field:

  {
    ...
    "unit": {
      "system-password": "YourPaSsWoRd"
    }
    ...
  }

Every time the password is updated a deviceupdate message
(with the new password) is sent to the GW.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I9c8eb49a62402807d9de61e8020637da57986e52
2024-01-22 17:36:01 +02:00
Serhiy Boiko
a328cd6b7a mac-address-list: Add overflow flag
The flag is set in two cases:
- if the value of wired-clients-max-num is set to 0
- if the number of learned mac addrs is greater than
  the value of wired-clients-max-num

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I73b46dbb213a91f6375ec33106e84fed50d30ac6
2024-01-22 17:32:06 +02:00
Serhiy Boiko
7afff76db1 proto: Fill platform state with learned mac addresses
JSON message to GW:

    "mac-forwarding-table": {
        "Ethernet0": {
            "100": [ "11:11:11:11:11:11", "22:22:22:22:22:22" ],
            "200": [ "33:33:33:33:33:33", "44:44:44:44:44:44" ]
        },
        "Ethernet1": {
            "100": [ "55:55:55:55:55:55", "66:66:66:66:66:66" ],
            "200": [ "77:77:77:77:77:77", "88:88:88:88:88:88" ]
        }
    }

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I49a4380225bc105a880731df367df3efbd0f4908
2024-01-22 17:32:06 +02:00
Oleksandr Mazur
0d9af851b4 Update build number 1.6 b4
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I2df8401d9437179e9564b5cae3aa34428f1ce5c1
2024-01-22 17:32:06 +02:00
Serhiy Boiko
b8c952cf1c plat: Add learned_mac_addrs_get API
The API will store the list of learned MAC addrs inside
of plat_state_info.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ib1e03c3fbc9f52ee9037e6bfca1c2c8fb2db56df
2024-01-22 17:32:06 +02:00
Serhiy Boiko
8636487247 gnma: Add mac_addr_list_get API
This API will return a list of fdb entries from the device.
The caller is responsible of providing a big enough buffer.
If the buffer is not big enough then a GNMA_ERR_OVERFLOW
error is returned and the list_size arg is set to the minimum
required size.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I8046549d9aff5903a068ea3ea2914dcb154a34da
2024-01-22 17:32:06 +02:00
Serhiy Boiko
ac20c4c276 Refactor router utils
Make for_router_db_diff macro more readible.
Use int instead of bool in _fib_info_cmp.
This also fixes the case where unreachable routes were not
rejected by the device if they were replacing blackhole
routes with the same prefix.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ic560ce85e506715509437de765de535172ccbf67
2024-01-22 17:32:06 +02:00
Oleksandr Mazur
ee4b0ca66b Update build number 1.6 b3
Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I9aaa730610dd3f107e146be72f113964447d72d9
2024-01-22 17:31:27 +02:00
Oleksandr Mazur
977c651079 Add unavailable reboot-case handler
Whenever system is not yet ready to determine reboot-cause
send an appropriate unavailable reboot cause msg, do not
default to <crash>.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Change-Id: I33130375889ccf689f4e5bcc4e6ee0b5ceb6f76e
2024-01-22 17:31:27 +02:00
Yevhen Orlov
3beb5f314b Update build number 1.6 b2
Signed-off-by: Yevhen Orlov <yevhen.orlov@plvision.eu>

Change-Id: If2c54a2c44dbe90c615dcb15f4c9fb285eb7a364
2024-01-22 17:31:27 +02:00
Serhiy Boiko
a84bfa8e04 Fix segfault caused by blackhole routes
The for loop incorrectly handles the array of routes which causes
a NULL pointer dereference in case that we have any routes
configured at device init (e.g. blackhole).
If we don't have any routes at init time the loop is skipped and
the issue is not reproduced.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I5f3656c470141fbfad3ceb268d91f755e33cf65f
2024-01-22 17:31:27 +02:00
Yevhen Orlov
289c74a81d Add parameters overriding in order to be sure after upgrade
Change-Id: I43b25ea6717403dfb871c67549bc248fd22f09b9
2024-01-22 17:31:27 +02:00
Yevhen Orlov
be1138ebc6 Revert "Add MGMT_VRF config to config_db.json"
This reverts commit d85cd586a8bedef86f4793befea42b6e511d2254.

Decide to do so, because we has multiple issues regarding that some
services startted especially for mgmt vrf so unavalible in case that
eth0 is not used in our scenarios.

Change-Id: I5fd53edba7d54acc61efa624ea798c169775a3ad
2024-01-22 17:31:27 +02:00
Serhiy Boiko
764e9f93ab Update revision naming format
Introduce a define (PLATFORM_REVISION) that can be used to
represent the current platform revision.
The new format is: "Rel %s build %s"
PLATFORM_REVISION can be passed to the make cmd as an env variable.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: Ifab6df704946fe283a102b1985afe9cedc39eba7
2024-01-22 17:31:27 +02:00
Serhiy Boiko
12117ebfc8 Fix Spanning Tree configuration
Set parameters per vlan instead of globally.

Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Change-Id: I011db1d4a800d0dc8463932fe692c4b57f898a55
2024-01-22 17:28:59 +02:00
40 changed files with 4383 additions and 694 deletions

View File

@@ -2,8 +2,11 @@ FROM debian:buster
LABEL Description="Ucentral client (Build) environment"
ARG HOME /root
ARG EXTERNAL_LIBS ${HOME}/ucentral-external-libs
ARG SCHEMA="3.2.7"
ARG SCHEMA_VERSION="v${SCHEMA}"
ARG SCHEMA_ZIP_FILE="${SCHEMA_VERSION}.zip"
ARG SCHEMA_UNZIPPED="ols-ucentral-schema-${SCHEMA}"
ARG OLS_SCHEMA_SRC="https://github.com/Telecominfraproject/ols-ucentral-schema/archive/refs/tags/${SCHEMA_ZIP_FILE}"
SHELL ["/bin/bash", "-c"]
RUN apt-get update -q -y && apt-get -q -y --no-install-recommends install \
@@ -15,19 +18,24 @@ RUN apt-get update -q -y && apt-get -q -y --no-install-recommends install \
libcurl4-openssl-dev \
libev-dev \
libssl-dev \
libnl-route-3-dev \
libnl-3-dev \
apt-utils \
git \
wget \
autoconf \
libtool \
pkg-config \
libjsoncpp-dev
libjsoncpp-dev \
unzip
RUN git config --global http.sslverify false
RUN git clone https://github.com/DaveGamble/cJSON.git ${HOME}/ucentral-external-libs/cJSON/
RUN git clone https://libwebsockets.org/repo/libwebsockets ${HOME}/ucentral-external-libs/libwebsockets/
RUN git clone --recurse-submodules -b v1.50.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc ${HOME}/ucentral-external-libs/grpc/
RUN git clone --recursive --branch v7.1.4 https://github.com/zhaojh329/rtty.git ${HOME}/ucentral-external-libs/rtty/
ADD ${OLS_SCHEMA_SRC} /tmp/
# The following libs should be prebuilt in docker-build-env img to speed-up
# recompilation of only the ucentral-client itself
@@ -60,3 +68,8 @@ RUN cd ${HOME}/ucentral-external-libs/rtty/ && \
cd build && \
cmake .. && \
make -j4
RUN unzip /tmp/${SCHEMA_ZIP_FILE} -d ${HOME}/ucentral-external-libs/
RUN cd ${HOME}/ucentral-external-libs/ && \
mv ${SCHEMA_UNZIPPED} ols-ucentral-schema

28
LICENSE Normal file
View File

@@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2024, Telecom Infra Project
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -32,6 +32,7 @@ run-host-env: build-host-env
docker run -d -t --name ${CONTAINER_NAME} \
-v $(realpath ./):/root/ols-nos \
--env UCENTRAL_PLATFORM=$(UCENTRAL_PLATFORM) \
--env PLATFORM_REVISION="$(PLATFORM_REVISION)" \
${IMG_ID}:${IMG_TAG} \
bash
@@ -49,8 +50,13 @@ build-ucentral-app: run-host-env
@echo Running ucentralclient docker-build-env container to build ucentral-client...;
docker exec -t ${CONTAINER_NAME} /root/ols-nos/docker-build-client.sh
docker cp ${CONTAINER_NAME}:/root/deliverables/ src/docker/
# copy the schema version, if it is there
docker cp ${CONTAINER_NAME}:/root/ucentral-external-libs/ols-ucentral-schema/schema.json src/docker/ || true
docker container stop ${CONTAINER_NAME} > /dev/null 2>&1 || true;
docker container rm ${CONTAINER_NAME} > /dev/null 2>&1 || true;
if [ -f version.json ]; then
cp version.json src/docker/
fi
build-ucentral-docker-img: build-ucentral-app
pushd src
@@ -90,6 +96,8 @@ clean:
rm -rf src/docker/deliverables || true;
rm -rf src/docker/lib* || true;
rm -rf src/docker/ucentral-client || true;
rm -rf src/docker/version.json || true;
rm -rf src/docker/schema.json || true;
rm -rf src/debian/ucentral-client.substvars 2>/dev/null || true;
rm -rf src/debian/shasta-ucentral-client.debhelper.log 2>/dev/null || true;
rm -rf src/debian/.debhelper src/debian/ucentral-client 2>/dev/null || true;

View File

@@ -11,7 +11,7 @@ cfg2:
cfg3:
Bring ports 1 up, 2 up (Ethernet1, Ethernet2) (admin state);
Destroy any VLAN that is not in the list (in this particular CFG - create VLAN 10,
destroye any other, except for MGMT VLAN 1 - it's not being altered by the
destroy any other, except for MGMT VLAN 1 - it's not being altered by the
uCentral app itself);
Create VLAN 10;
Set VLAN 10 memberlist with the following ports: Ethernet1, Ethernet2;
@@ -39,6 +39,7 @@ cfg5_poe:
- detection mode is 4pt-dot3af;
- power limit is 99900mW (e.g. max per port);
- priority is LOW;
cfg7_ieee80211x.json:
Following json file configures the given topology:
+-----------------+
@@ -64,3 +65,33 @@ cfg7_ieee80211x.json:
to be the same for the given (10.10.20.0/24) network.
.1x client also must have a valid credentials data (both client and radius server
must have same clients credentials configured).
cfg_igmp.json:
Configure igmp snooping and querier on VLAN 1.
Configure igmp static groups:
- 230.1.1.1 with egress port Ethernet1
- 230.2.2.2 with egress ports Ethernet2 & Ethernet3
cfg_rpvstp.json:
Configure VLAN 1;
Configure VLAN 2;
Configure rapid per-vlan STP on VLAN 1 with priority 32768;
Disable STP on VLAN 2.
cfg_port_isolation.json:
Configure port isolation with Ethernet1 as uplink and
Ethernet2 & Ethernet3 as downlink
cfg_services_log.json:
Enable syslog with these parameters:
- remote host addr
- remote host port
- log severity (priority):
* emerg: 0
* alert: 1
* crit: 2
* error: 3
* warning: 4
* notice: 5
* info: 6
* debug: 7

View File

@@ -1,70 +1,70 @@
{
"ethernet": [
{
"duplex": "full",
"enabled": false,
"speed": 1000,
"select-ports": [
"Ethernet0",
"Ethernet1",
"Ethernet2",
"Ethernet3",
"Ethernet4",
"Ethernet5",
"Ethernet6",
"Ethernet7",
"Ethernet8",
"Ethernet9",
"Ethernet10",
"Ethernet11",
"Ethernet12",
"Ethernet13",
"Ethernet14",
"Ethernet15",
"Ethernet16",
"Ethernet17",
"Ethernet18",
"Ethernet19",
"Ethernet20",
"Ethernet21",
"Ethernet22",
"Ethernet23",
"Ethernet24",
"Ethernet25",
"Ethernet26",
"Ethernet27",
"Ethernet28",
"Ethernet29",
"Ethernet30",
"Ethernet31",
"Ethernet32",
"Ethernet33",
"Ethernet34",
"Ethernet35",
"Ethernet36",
"Ethernet37",
"Ethernet38",
"Ethernet39",
"Ethernet40",
"Ethernet41",
"Ethernet42",
"Ethernet43",
"Ethernet44",
"Ethernet45",
"Ethernet46",
"Ethernet47",
"Ethernet48",
"Ethernet52",
"Ethernet56",
"Ethernet60",
"Ethernet64",
"Ethernet68",
"Ethernet72",
"Ethernet76"
]
}
],
"interfaces": [],
"services": {},
"uuid": 1
}
{
"ethernet": [
{
"duplex": "full",
"enabled": false,
"speed": 1000,
"select-ports": [
"Ethernet0",
"Ethernet1",
"Ethernet2",
"Ethernet3",
"Ethernet4",
"Ethernet5",
"Ethernet6",
"Ethernet7",
"Ethernet8",
"Ethernet9",
"Ethernet10",
"Ethernet11",
"Ethernet12",
"Ethernet13",
"Ethernet14",
"Ethernet15",
"Ethernet16",
"Ethernet17",
"Ethernet18",
"Ethernet19",
"Ethernet20",
"Ethernet21",
"Ethernet22",
"Ethernet23",
"Ethernet24",
"Ethernet25",
"Ethernet26",
"Ethernet27",
"Ethernet28",
"Ethernet29",
"Ethernet30",
"Ethernet31",
"Ethernet32",
"Ethernet33",
"Ethernet34",
"Ethernet35",
"Ethernet36",
"Ethernet37",
"Ethernet38",
"Ethernet39",
"Ethernet40",
"Ethernet41",
"Ethernet42",
"Ethernet43",
"Ethernet44",
"Ethernet45",
"Ethernet46",
"Ethernet47",
"Ethernet48",
"Ethernet52",
"Ethernet56",
"Ethernet60",
"Ethernet64",
"Ethernet68",
"Ethernet72",
"Ethernet76"
]
}
],
"interfaces": [],
"services": {},
"uuid": 1
}

View File

@@ -1,16 +1,16 @@
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1",
"Ethernet2"
]
}
],
"interfaces": [],
"services": {},
"uuid": 1
}
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1",
"Ethernet2"
]
}
],
"interfaces": [],
"services": {},
"uuid": 1
}

View File

@@ -1,23 +1,23 @@
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1"
]
},
{
"duplex": "full",
"enabled": false,
"select-ports": [
"Ethernet2"
],
"speed": 1000
}
],
"interfaces": [],
"services": {},
"uuid": 2
}
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1"
]
},
{
"duplex": "full",
"enabled": false,
"select-ports": [
"Ethernet2"
],
"speed": 1000
}
],
"interfaces": [],
"services": {},
"uuid": 2
}

View File

@@ -1,35 +1,35 @@
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1",
"Ethernet2"
]
}
],
"interfaces": [
{
"vlan": {
"id": 10,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet1",
"Ethernet2"
],
"vlan-tag": "tagged"
}
],
"name": "mgmt",
"role": "upstream",
"services": []
}
],
"services": {},
"uuid": 3
}
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1",
"Ethernet2"
]
}
],
"interfaces": [
{
"vlan": {
"id": 10,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet1",
"Ethernet2"
],
"vlan-tag": "tagged"
}
],
"name": "mgmt",
"role": "upstream",
"services": []
}
],
"services": {},
"uuid": 3
}

View File

@@ -1,51 +1,51 @@
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1",
"Ethernet2"
]
}
],
"interfaces": [
{
"vlan": {
"id": 10,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet1"
],
"vlan-tag": "tagged"
}
],
"name": "mgmt",
"role": "upstream",
"services": []
},
{
"vlan": {
"id": 100,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet2"
],
"vlan-tag": "tagged"
}
],
"name": "mgmt",
"role": "upstream",
"services": []
}
],
"services": {},
"uuid": 3
}
{
"ethernet": [
{
"duplex": "full",
"enabled": true,
"speed": 1000,
"select-ports": [
"Ethernet1",
"Ethernet2"
]
}
],
"interfaces": [
{
"vlan": {
"id": 10,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet1"
],
"vlan-tag": "tagged"
}
],
"name": "mgmt",
"role": "upstream",
"services": []
},
{
"vlan": {
"id": 100,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet2"
],
"vlan-tag": "tagged"
}
],
"name": "mgmt",
"role": "upstream",
"services": []
}
],
"services": {},
"uuid": 3
}

View File

@@ -17,7 +17,11 @@
{
"ipv4": {
"addressing": "static",
"subnet": "20.20.20.20/24",
"subnet": [
{
"prefix": "20.20.20.20/24"
}
],
"dhcp": {
"relay-server": "172.20.254.8",
"circuit-id-format": "{Name}:{VLAN-ID}"
@@ -44,7 +48,11 @@
{
"ipv4": {
"addressing": "static",
"subnet": "30.30.30.30/24",
"subnet": [
{
"prefix": "30.30.30.30/24"
}
],
"dhcp": {
"relay-server": "172.20.10.12",
"circuit-id-format": "{Name}:{VLAN-ID}"
@@ -71,7 +79,11 @@
{
"ipv4": {
"addressing": "static",
"subnet": "172.20.10.181/24"
"subnet": [
{
"prefix": "172.20.10.181/24"
}
]
},
"vlan": {
"id": 20,

View File

@@ -50,7 +50,11 @@
},
"ipv4": {
"addressing": "static",
"subnet": "10.10.20.100/24"
"subnet": [
{
"prefix": "10.10.20.100/24"
}
]
},
"ethernet": [
{
@@ -70,7 +74,11 @@
},
"ipv4": {
"addressing": "static",
"subnet": "10.10.50.100/24"
"subnet": [
{
"prefix": "10.10.50.100/24"
}
]
},
"ethernet": [
{

View File

@@ -0,0 +1,64 @@
{
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"speed": 1000,
"duplex": "full",
"enabled": true,
"poe": {
"admin-mode": true
}
}
],
"interfaces": [
{
"vlan": {
"id": 1,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"vlan-tag": "un-tagged"
}
],
"ipv4": {
"multicast": {
"igmp": {
"querier-enable": true,
"query-interval": 60,
"snooping-enable": true,
"version": 3,
"static-mcast-groups": [
{
"address": "230.1.1.1",
"egress-ports": [
"Ethernet1"
]
},
{
"address": "230.2.2.2",
"egress-ports": [
"Ethernet2",
"Ethernet3"
]
}
]
}
},
"subnet": [
{
"prefix": "1.1.1.1/24"
}
]
},
"role": "upstream",
"name": "mgmt-vlan"
}
],
"uuid": 1
}

View File

@@ -0,0 +1,54 @@
{
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"speed": 1000,
"duplex": "full",
"enabled": true,
"poe": {
"admin-mode": true
}
}
],
"interfaces": [
{
"vlan": {
"id": 1,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"vlan-tag": "un-tagged"
}
],
"role": "upstream",
"name": "mgmt-vlan"
}
],
"switch": {
"port-isolation": {
"sessions": [
{
"id": 1,
"uplink": {
"interface-list": [
"Ethernet1"
]
},
"downlink": {
"interface-list": [
"Ethernet2",
"Ethernet3"
]
}
}
]
}
},
"uuid": 1
}

View File

@@ -0,0 +1,66 @@
{
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"speed": 1000,
"duplex": "full",
"enabled": true,
"poe": {
"admin-mode": true
}
}
],
"interfaces": [
{
"vlan": {
"id": 1,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"vlan-tag": "un-tagged"
}
],
"role": "upstream",
"name": "mgmt-vlan"
},
{
"vlan": {
"id": 2,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"vlan-tag": "tagged"
}
],
"role": "upstream",
"name": "mgmt-vlan"
}
],
"switch": {
"loop-detection": {
"protocol": "rpvstp",
"instances": [
{
"id": 1,
"enabled": true,
"priority": 32768
},
{
"id": 2,
"enabled": false
}
]
}
},
"uuid": 1
}

View File

@@ -0,0 +1,43 @@
{
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"speed": 1000,
"duplex": "full",
"enabled": true,
"poe": {
"admin-mode": true
}
}
],
"interfaces": [
{
"vlan": {
"id": 1,
"proto": "802.1q"
},
"ethernet": [
{
"select-ports": [
"Ethernet*"
],
"vlan-tag": "un-tagged"
}
],
"role": "upstream",
"name": "mgmt-vlan"
}
],
"services": {
"log": {
"port": 2000,
"priority": 7,
"size": 1000,
"host": "192.168.1.10",
"proto": "udp"
}
},
"uuid": 1
}

View File

@@ -36,6 +36,7 @@ override_dh_install:
# home folder.
mkdir -p ${INSTALL}/home/admin
cp scripts/OLS_NOS_fixups.script ${INSTALL}/usr/local/lib
cp scripts/OLS_NOS_upgrade_override.script ${INSTALL}/usr/local/lib
cp docker-ucentral-client.gz ${INSTALL}/usr/local/lib
# Install Vlan1 in-band management configuration
mkdir -p ${INSTALL}/etc/network/interfaces.d/

View File

@@ -21,6 +21,8 @@ COPY /ucentral-client /usr/local/bin/ucentral-client
COPY /rtty /usr/local/bin/
COPY /lib* /usr/local/lib/
COPY /version.jso[n] /etc/
COPY /schema.jso[n] /etc/
RUN ldconfig
RUN ls -l /usr/local/bin/ucentral-client

View File

@@ -4,3 +4,8 @@ ntp server 1.pool.ntp.org prefer true
ntp server 2.pool.ntp.org prefer true
ntp server 3.pool.ntp.org prefer true
ntp authenticate
ip dhcp snooping
ip dhcp snooping Vlan1
ntp source-interface Vlan 1
interface range Ethernet 0-100
no ip dhcp snooping trust

View File

@@ -0,0 +1,2 @@
configure terminal
no ip vrf mgmt

View File

@@ -11,6 +11,7 @@ start() {
fi
cp /usr/local/lib/OLS_NOS_fixups.script /home/admin/OLS_NOS_fixups.script
cp /usr/local/lib/OLS_NOS_upgrade_override.script /home/admin/OLS_NOS_upgrade_override.script
if [ $(systemctl is-active config-setup.service) == "active" ]; then
# do nothing on service restart
@@ -29,11 +30,23 @@ start() {
}
wait() {
test -d /var/lib/ucentral || mkdir /var/lib/ucentral
# Wait for at least one Vlan to be created - a signal that telemetry is up.
# Even if vlan table is empty, private 3967 will be allocated with all
# ports in it.
while ! ls /sys/class/net/Vlan* &>/dev/null; do sleep 1; done
# Detect first boot on this version
# Run upgrade overrides before fixups
conf_upgrade_md5sum=$(md5sum /home/admin/OLS_NOS_upgrade_override.script | cut -d ' ' -f1)
if test "$conf_upgrade_md5sum" != "$(test -f /var/lib/ucentral/upgrade-override.md5sum && cat /var/lib/ucentral/upgrade-override.md5sum)"; then
sudo -u admin -- bash "sonic-cli" "/home/admin/OLS_NOS_upgrade_override.script"
echo -n "$conf_upgrade_md5sum" >/var/lib/ucentral/upgrade-override.md5sum
fi
sudo touch /etc/default/in-band-dhcp
# Temporary NTP fixup / WA: configure a list of default NTP servers.
# Should mature into a default-config option to make sure board has right
# time upon any boot (especially first time).
@@ -48,6 +61,8 @@ wait() {
# NOTE: alternatively we could use ifplugd. This also handle del/add scenario
ifup Vlan1 || true
config vlan dhcp 1 enable
# There's an issue with containers starting before DNS server is configured:
# resolf.conf file get copied from host to container upon container start.
# This means, that if resolf.conf gets altered (on host) after container's been
@@ -63,9 +78,19 @@ wait() {
# This also means, that we won't start up untill this URI is accessible.
while ! curl clientauth.one.digicert.com &>/dev/null; do sleep 1; done
# Enable DHCP trusting for uplink (Vlan1) iface
# It's needed to forward DHCP Discover (and replies) from/to DHCP server
# of (untrusted) port clients (EthernetX) of the same Vlan (Vlan1).
# Without this fix underlying Vlan members wouldn't be able to receive
# DHCP-lease IP
trusted_dhcp_if=`sudo -u admin -- bash "sonic-cli" "-c" "show ip arp" | grep -Eo "Ethernet[0-9]+"`
sudo -u admin -- "echo" "configure terminal" > /home/admin/fixup_scr.script
sudo -u admin -- "echo" "interface $trusted_dhcp_if" >> /home/admin/fixup_scr.script
sudo -u admin -- "echo" "ip dhcp snooping trust" >> /home/admin/fixup_scr.script
sudo -u admin -- bash "sonic-cli" "/home/admin/fixup_scr.script"
# change admin password
# NOTE: This could lead to access escalation, if you got image from running device
test -d /var/lib/ucentral || mkdir /var/lib/ucentral
if ! test -f /var/lib/ucentral/admin-cred.changed; then
#ADMIN_PASSWD=`openssl rand -hex 10`
ADMIN_PASSWD=broadcom

View File

@@ -154,6 +154,11 @@
"vlanid": "1"
}
},
"VLAN_INTERFACE": {
"Vlan1": {
"dhcp": "enable"
}
},
"VLAN_MEMBER": {
{% for port in PORT %}
"Vlan1|{{port}}": {
@@ -164,11 +169,6 @@
"INTERFACE": {
"Vlan1": {}
},
"MGMT_VRF_CONFIG": {
"vrf_global": {
"mgmtVrfEnabled": "true"
}
},
"VRF": {
"default": {
"enabled": "true"

View File

@@ -46,16 +46,16 @@ struct ucentral_router {
struct ucentral_router_fib_db_apply_args {
/* plat whould check info to determine if node channged */
int (*upd_cb)(const struct ucentral_router_fib_node *old,
int (*upd_cb)(const struct ucentral_router_fib_node *old_node,
int olen,
const struct ucentral_router_fib_node *new,
const struct ucentral_router_fib_node *new_node,
int nlen,
void *arg);
/* prefix = new, info = new */
int (*add_cb)(const struct ucentral_router_fib_node *new,
int (*add_cb)(const struct ucentral_router_fib_node *new_node,
int len, void *arg);
/* prefix = none */
int (*del_cb)(const struct ucentral_router_fib_node *old,
int (*del_cb)(const struct ucentral_router_fib_node *old_node,
int len, void *arg);
void *arg;
};
@@ -69,26 +69,26 @@ int ucentral_router_fib_db_append(struct ucentral_router *r,
struct ucentral_router_fib_node *n);
int ucentral_router_fib_key_cmp(const struct ucentral_router_fib_key *a,
const struct ucentral_router_fib_key *b);
bool ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
const struct ucentral_router_fib_info *b);
int ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
const struct ucentral_router_fib_info *b);
#define router_db_get(R, I) (I < (R)->len ? &(R)->arr[(I)] : NULL)
#define for_router_db_diff_CASE_UPD(DIFF) if (!(DIFF))
#define for_router_db_diff_CASE_DEL(DIFF) if ((DIFF) > 0)
#define for_router_db_diff_CASE_ADD(DIFF) if ((DIFF) < 0)
#define diff_case_upd(DIFF) (!(DIFF))
#define diff_case_del(DIFF) ((DIFF) > 0)
#define diff_case_add(DIFF) ((DIFF) < 0)
#define router_db_diff_get(NEW, OLD, INEW, IOLD) \
(IOLD) == (OLD)->len \
? -1 \
: (INEW) == (NEW)->len \
? 1 \
: ucentral_router_fib_key_cmp(&(NEW)->arr[(INEW)].key, &(OLD)->arr[(IOLD)].key)
#define for_router_db_diff(NEW, OLD, INEW, IOLD, DIFF) \
for ((INEW) = 0, (IOLD) = 0, (NEW)->sorted ? 0 : ucentral_router_fib_db_sort((NEW)), (OLD)->sorted ? 0 : ucentral_router_fib_db_sort((OLD)); \
((IOLD) != (OLD)->len || (INEW) != (NEW)->len) && \
(( \
(DIFF) = (IOLD) == (OLD)->len ? -1 : (INEW) == (NEW)->len ? 1 : ucentral_router_fib_key_cmp(&(NEW)->arr[(INEW)].key, &(OLD)->arr[(IOLD)].key) \
) || 1); \
(DIFF) == 0 ? ++(INEW) && ++(IOLD) : 0, (DIFF) > 0 ? ++(IOLD) : 0, (DIFF) < 0 ? ++(INEW) : 0\
for ((INEW) = 0, (IOLD) = 0, (DIFF) = 0; \
\
((IOLD) != (OLD)->len || (INEW) != (NEW)->len); \
\
(DIFF) == 0 ? ++(INEW) && ++(IOLD) : 0, \
(DIFF) > 0 ? ++(IOLD) : 0, \
(DIFF) < 0 ? ++(INEW) : 0 \
)
/*
* ((DIFF) == 0 && ++(INEW) && ++(IOLD)) || \
* ((DIFF) > 0 && ++(IOLD)) || \
* ((DIFF) < 0 && ++(INEW)) \
*/

View File

@@ -31,6 +31,8 @@ extern "C" {
#define RADIUS_CFG_DEFAULT_PRIO (1)
#define HEALTHCHEK_MESSAGE_MAX_COUNT (10)
#define HEALTHCHEK_MESSAGE_MAX_LEN (100)
#define PLATFORM_MAC_STR_SIZE (18)
#define METRICS_WIRED_CLIENTS_MAX_NUM (2000)
/*
* TODO(vb) likely we need to parse interfaces in proto to understand
@@ -39,6 +41,8 @@ extern "C" {
*/
#define PID_TO_NAME(p, name) sprintf(name, "Ethernet%hu", p)
#define NAME_TO_PID(p, name) sscanf((name), "Ethernet%hu", (p))
#define VLAN_TO_NAME(v, name) sprintf((name), "Vlan%hu", (v))
#define NAME_TO_VLAN(v, name) sscanf((name), "Vlan%hu", (v))
struct plat_vlan_memberlist;
struct plat_port_vlan;
@@ -62,6 +66,18 @@ enum plat_ieee8021x_port_host_mode {
PLAT_802_1X_PORT_HOST_MODE_SINGLE_HOST,
};
enum plat_ieee8021x_das_auth_type {
PLAT_802_1X_DAS_AUTH_TYPE_ANY,
PLAT_802_1X_DAS_AUTH_TYPE_ALL,
PLAT_802_1X_DAS_AUTH_TYPE_SESSION_KEY,
};
enum plat_igmp_version {
PLAT_IGMP_VERSION_1,
PLAT_IGMP_VERSION_2,
PLAT_IGMP_VERSION_3
};
#define UCENTRAL_PORT_LLDP_PEER_INFO_MAX_MGMT_IPS (2)
/* Interface LLDP peer's data, as defined in interface.lldp.yml*/
struct plat_port_lldp_peer_info {
@@ -75,7 +91,7 @@ struct plat_port_lldp_peer_info {
/* The chassis name that our neighbour is announcing */
char name[64];
/* The chassis MAC that our neighbour is announcing */
char mac[18];
char mac[PLATFORM_MAC_STR_SIZE];
/* The chassis description that our neighbour is announcing */
char description[512];
/* The management IPs that our neighbour is announcing */
@@ -113,7 +129,7 @@ struct plat_poe_port_state {
struct plat_ieee8021x_authenticated_client_info {
char auth_method[32];
char mac_addr[18];
char mac_addr[PLATFORM_MAC_STR_SIZE];
size_t session_time;
char username[64];
char vlan_type[32];
@@ -250,10 +266,27 @@ struct plat_port_l2 {
struct plat_ipv4 ipv4;
};
struct plat_igmp {
bool exist;
bool snooping_enabled;
bool querier_enabled;
bool fast_leave_enabled;
uint32_t query_interval;
uint32_t last_member_query_interval;
uint32_t max_response_time;
enum plat_igmp_version version;
size_t num_groups;
struct {
struct in_addr addr;
struct plat_ports_list *egress_ports_list;
} *groups;
};
struct plat_port_vlan {
struct plat_vlan_memberlist *members_list_head;
struct plat_ipv4 ipv4;
struct plat_dhcp dhcp;
struct plat_igmp igmp;
uint16_t id;
uint16_t mstp_instance;
};
@@ -280,6 +313,18 @@ struct plat_syslog_cfg {
char host[SYSLOG_CFG_FIELD_STR_MAX_LEN];
};
struct plat_enabled_service_cfg {
struct {
bool enabled;
} ssh;
struct telnet {
bool enabled;
} telnet;
struct {
bool enabled;
} http;
};
struct plat_rtty_cfg {
char id[RTTY_CFG_FIELD_STR_MAX_LEN];
char passwd[RTTY_CFG_FIELD_STR_MAX_LEN];
@@ -322,6 +367,7 @@ struct plat_metrics_cfg {
int lldp_enabled;
int clients_enabled;
size_t interval;
unsigned max_mac_count;
/* IE GET max length. Should be enoug. */
char public_ip_lookup[2048];
} state;
@@ -334,8 +380,16 @@ struct plat_unit_poe_cfg {
bool is_usage_threshold_set;
};
struct plat_unit_system_cfg {
char password[64];
bool password_changed;
};
struct plat_unit {
struct plat_unit_poe_cfg poe;
struct plat_unit_system_cfg system;
bool mc_flood_control;
bool querier_enable;
};
enum plat_stp_mode {
@@ -367,6 +421,31 @@ struct plat_radius_hosts_list {
struct plat_radius_host host;
};
struct plat_ieee8021x_dac_host {
char hostname[RADIUS_CFG_HOSTNAME_STR_MAX_LEN];
char passkey[RADIUS_CFG_PASSKEY_STR_MAX_LEN];
};
struct plat_ieee8021x_dac_list {
struct plat_ieee8021x_dac_list *next;
struct plat_ieee8021x_dac_host host;
};
struct plat_port_isolation_session_ports {
struct plat_ports_list *ports_list;
};
struct plat_port_isolation_session {
uint64_t id;
struct plat_port_isolation_session_ports uplink;
struct plat_port_isolation_session_ports downlink;
};
struct plat_port_isolation_cfg {
struct plat_port_isolation_session *sessions;
size_t sessions_num;
};
struct plat_cfg {
struct plat_unit unit;
/* Alloc all ports, but access them only if bit is set. */
@@ -376,6 +455,7 @@ struct plat_cfg {
BITMAP_DECLARE(vlans_to_cfg, MAX_VLANS);
struct plat_metrics_cfg metrics;
struct plat_syslog_cfg *log_cfg;
struct plat_enabled_service_cfg enabled_services_cfg;
/* Port's interfaces (provide l2 iface w/o bridge caps) */
struct plat_port_l2 portsl2[MAX_NUM_OF_PORTS];
struct ucentral_router router;
@@ -384,9 +464,24 @@ struct plat_cfg {
/* Instance zero is for global instance (like common values in rstp) */
struct plat_stp_instance_cfg stp_instances[MAX_VLANS];
struct plat_radius_hosts_list *radius_hosts_list;
bool ieee8021x_is_auth_ctrl_enabled;
struct {
bool is_auth_ctrl_enabled;
bool bounce_port_ignore;
bool disable_port_ignore;
bool ignore_server_key;
bool ignore_session_key;
char server_key[RADIUS_CFG_PASSKEY_STR_MAX_LEN];
enum plat_ieee8021x_das_auth_type das_auth_type;
struct plat_ieee8021x_dac_list *das_dac_list;
} ieee8021x;
struct plat_port_isolation_cfg port_isolation_cfg;
};
struct plat_learned_mac_addr {
char port[PORT_MAX_NAME_LEN];
int vid;
char mac[PLATFORM_MAC_STR_SIZE];
};
typedef void (*plat_alarm_cb)(struct plat_alarm *);
@@ -486,17 +581,60 @@ enum {
PLAT_REBOOT_CAUSE_REBOOT_CMD,
PLAT_REBOOT_CAUSE_POWERLOSS,
PLAT_REBOOT_CAUSE_CRASH,
PLAT_REBOOT_CAUSE_UNAVAILABLE,
};
enum sfp_form_factor {
UCENTRAL_SFP_FORM_FACTOR_NA = 0,
UCENTRAL_SFP_FORM_FACTOR_SFP,
UCENTRAL_SFP_FORM_FACTOR_SFP_PLUS,
UCENTRAL_SFP_FORM_FACTOR_SFP_28,
UCENTRAL_SFP_FORM_FACTOR_SFP_DD,
UCENTRAL_SFP_FORM_FACTOR_QSFP,
UCENTRAL_SFP_FORM_FACTOR_QSFP_PLUS,
UCENTRAL_SFP_FORM_FACTOR_QSFP_28,
UCENTRAL_SFP_FORM_FACTOR_QSFP_DD
};
enum sfp_link_mode {
UCENTRAL_SFP_LINK_MODE_NA = 0,
UCENTRAL_SFP_LINK_MODE_1000_X,
UCENTRAL_SFP_LINK_MODE_2500_X,
UCENTRAL_SFP_LINK_MODE_4000_SR,
UCENTRAL_SFP_LINK_MODE_10G_SR,
UCENTRAL_SFP_LINK_MODE_25G_SR,
UCENTRAL_SFP_LINK_MODE_40G_SR,
UCENTRAL_SFP_LINK_MODE_50G_SR,
UCENTRAL_SFP_LINK_MODE_100G_SR,
};
struct plat_port_transceiver_info {
char vendor_name[64];
char part_number[64];
char serial_number[64];
char revision[64];
enum sfp_form_factor form_factor;
enum sfp_link_mode *supported_link_modes;
size_t num_supported_link_modes;
float temperature;
float tx_optical_power;
float rx_optical_power;
float max_module_power;
};
struct plat_port_info {
struct plat_port_counters stats;
struct plat_port_lldp_peer_info lldp_peer_info;
struct plat_ieee8021x_port_info ieee8021x_info;
struct plat_port_transceiver_info transceiver_info;
uint32_t uptime;
uint32_t speed;
uint8_t carrier_up;
uint8_t duplex;
uint8_t has_lldp_peer_info;
uint8_t has_transceiver_info;
char name[PORT_MAX_NAME_LEN];
};
@@ -510,6 +648,24 @@ struct plat_system_info {
double load_average[3]; /* 1, 5, 15 minutes load average */
};
struct plat_iee8021x_coa_counters {
uint64_t coa_req_received;
uint64_t coa_ack_sent;
uint64_t coa_nak_sent;
uint64_t coa_ignored;
uint64_t coa_wrong_attr;
uint64_t coa_wrong_attr_value;
uint64_t coa_wrong_session_context;
uint64_t coa_administratively_prohibited_req;
};
struct plat_gw_address {
struct in_addr ip;
uint32_t metric;
char port[PORT_MAX_NAME_LEN];
char mac[PLATFORM_MAC_STR_SIZE];
};
struct plat_state_info {
struct plat_poe_state poe_state;
struct plat_poe_port_state poe_ports_state[MAX_NUM_OF_PORTS];
@@ -517,8 +673,15 @@ struct plat_state_info {
struct plat_port_info *port_info;
int port_info_count;
struct plat_port_vlan *vlan_info;
size_t vlan_info_count;
struct plat_learned_mac_addr *learned_mac_list;
size_t learned_mac_list_size;
struct plat_gw_address *gw_addr_list;
size_t gw_addr_list_size;
struct plat_system_info system_info;
struct plat_iee8021x_coa_counters ieee8021x_global_coa_counters;
};
struct plat_upgrade_info {
@@ -544,7 +707,14 @@ struct plat_event_callbacks {
plat_poe_link_faultcode_cb poe_link_faultcode_cb;
};
enum plat_script_type {
PLAT_SCRIPT_TYPE_NA = 0,
PLAT_SCRIPT_TYPE_SHELL = 1,
PLAT_SCRIPT_TYPE_DIAGNOSTICS = 2,
};
struct plat_run_script_result {
enum plat_script_type type;
const char *stdout_string;
size_t stdout_string_len;
int exit_status;
@@ -552,7 +722,7 @@ struct plat_run_script_result {
};
struct plat_run_script {
const char *type;
enum plat_script_type type;
const char *script_base64;
plat_run_script_cb cb;
void *ctx;
@@ -602,11 +772,10 @@ int plat_run_script(struct plat_run_script *);
int plat_port_list_get(uint16_t list_size, struct plat_ports_list *ports);
int plat_port_num_get(uint16_t *num_of_active_ports);
int plat_running_img_name_get(char *str, size_t str_max_len);
int plat_revision_get(char *str, size_t str_max_len);
int
plat_reboot_cause_get(struct plat_reboot_cause *cause);
int plat_diagnostic(char *res_path);
#ifdef __cplusplus
}
#endif

View File

@@ -1,12 +1,19 @@
plat.a: plat.o
ar crs $@ $^
plat.o: plat-gnma.o gnma/gnma.full.a
plat.o: plat-gnma.o gnma/gnma.full.a netlink/netlink.full.a
# TODO(vb) get back to this
gcc -r -nostdlib -o $@ $^
gnma/gnma.full.a:
$(MAKE) -C $(dir $@) $(notdir $@)
netlink/netlink.full.a:
$(MAKE) -C $(dir $@) $(notdir $@)
%.o: %.c
ifdef PLATFORM_REVISION
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include -D PLATFORM_REVISION='"$(PLATFORM_REVISION)"' $^
else
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include $^
endif

View File

@@ -1,7 +1,7 @@
all: gnma.a
%.o: %.c
gcc -c -o $@ ${CFLAGS} -I ./ -I../../../include $<
gcc -c -o $@ ${CFLAGS} -I ./ -I../../../include -I../netlink $<
gnma.a: gnma_common.o
ar crs $@ $^

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,7 @@
#define GNMA_RADIUS_CFG_HOSTNAME_STR_MAX_LEN (64)
#define GNMA_RADIUS_CFG_PASSKEY_STR_MAX_LEN (64)
#define GNMA_OK 0
#define GNMA_ERR_COMMON -1
#define GNMA_ERR_OVERFLOW -2
@@ -26,6 +27,16 @@ struct gnma_radius_host_key {
char hostname[GNMA_RADIUS_CFG_HOSTNAME_STR_MAX_LEN];
};
struct gnma_das_dac_host_key {
char hostname[GNMA_RADIUS_CFG_HOSTNAME_STR_MAX_LEN];
};
typedef enum _gnma_das_auth_type_t {
GNMA_802_1X_DAS_AUTH_TYPE_ANY,
GNMA_802_1X_DAS_AUTH_TYPE_ALL,
GNMA_802_1X_DAS_AUTH_TYPE_SESSION_KEY,
} gnma_das_auth_type_t;
struct gnma_metadata {
char platform[GNMA_METADATA_STR_MAX_LEN];
char hwsku[GNMA_METADATA_STR_MAX_LEN];
@@ -58,6 +69,17 @@ typedef enum _gnma_port_stat_type_t {
} gnma_port_stat_type_t;
typedef enum _gnma_ieee8021x_das_dac_stat_type_t {
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_PKTS,
GNMA_IEEE8021X_DAS_DAC_STAT_OUT_COA_ACK_PKTS,
GNMA_IEEE8021X_DAS_DAC_STAT_OUT_COA_NAK_PKTS,
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_IGNORED_PKTS,
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_WRONG_ATTR_PKTS,
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_WRONG_ATTR_VALUE_PKTS,
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_WRONG_SESSION_CONTEXT_PKTS,
GNMA_IEEE8021X_DAS_DAC_STAT_IN_COA_ADMINISTRATIVELY_PROHIBITED_REQ_PKTS,
} gnma_ieee8021x_das_dac_stat_type_t;
struct gnma_alarm {
const char *id;
const char *resource;
@@ -129,7 +151,9 @@ struct gnma_route_attrs {
} connected;
struct {
uint16_t vid;
uint32_t metric;
struct in_addr gw;
struct gnma_port_key egress_port;
} nexthop;
};
};
@@ -256,6 +280,47 @@ struct gnma_vlan_member_bmap {
} vlan[GNMA_MAX_VLANS];
};
typedef enum _gnma_fdb_entry_type_t {
GNMA_FDB_ENTRY_TYPE_STATIC,
GNMA_FDB_ENTRY_TYPE_DYNAMIC,
} gnma_fdb_entry_type_t;
struct gnma_fdb_entry {
struct gnma_port_key port;
gnma_fdb_entry_type_t type;
int vid;
char mac[18];
};
typedef enum _gnma_igmp_version_t {
GNMA_IGMP_VERSION_NA = 0,
GNMA_IGMP_VERSION_1 = 1,
GNMA_IGMP_VERSION_2 = 2,
GNMA_IGMP_VERSION_3 = 3
} gnma_igmp_version_t;
struct gnma_igmp_snoop_attr {
bool enabled;
bool querier_enabled;
bool fast_leave_enabled;
uint32_t query_interval;
uint32_t last_member_query_interval;
uint32_t max_response_time;
gnma_igmp_version_t version;
};
struct gnma_igmp_static_group_attr {
struct in_addr address;
size_t num_ports;
struct gnma_port_key *egress_ports;
};
struct gnma_vlan_ip_t {
uint16_t vid;
uint16_t prefixlen;
struct in_addr address;
};
int gnma_switch_create(/* TODO id */ /* TODO: attr (adr, login, psw) */);
int gnma_port_admin_state_set(struct gnma_port_key *port_key, bool up);
int gnma_port_speed_set(struct gnma_port_key *port_key, const char *speed);
@@ -380,6 +445,9 @@ int gnma_route_remove(uint16_t vr_id /* 0 - default */,
int gnma_route_list_get(uint16_t vr_id, uint32_t *list_size,
struct gnma_ip_prefix *prefix_list,
struct gnma_route_attrs *attr_list);
int gnma_dyn_route_list_get(size_t *list_size,
struct gnma_ip_prefix *prefix_list,
struct gnma_route_attrs *attr_list);
int gnma_stp_mode_set(gnma_stp_mode_t mode, struct gnma_stp_attr *attr);
int gnma_stp_mode_get(gnma_stp_mode_t *mode, struct gnma_stp_attr *attr);
@@ -390,23 +458,53 @@ int gnma_stp_ports_enable(uint32_t list_size, struct gnma_port_key *ports_list);
int gnma_stp_instance_set(uint16_t instance, uint16_t prio,
uint32_t list_size, uint16_t *vid_list);
int gnma_stp_vids_enable(uint32_t list_size, uint16_t *vid_list);
int gnma_stp_vids_enable_all(void);
int gnma_stp_vids_set(uint32_t list_size, uint16_t *vid_list, bool enable);
int gnma_stp_vids_set_all(bool enable);
int gnma_stp_vid_set(uint16_t vid, struct gnma_stp_attr *attr);
int gnma_stp_vid_bulk_get(struct gnma_stp_attr *list, ssize_t size);
int gnma_ieee8021x_system_auth_control_set(bool is_enabled);
int gnma_ieee8021x_system_auth_control_get(bool *is_enabled);
int gnma_ieee8021x_system_auth_clients_get(char *buf, size_t buf_size);
int gnma_ieee8021x_das_bounce_port_ignore_set(bool bounce_port_ignore);
int gnma_ieee8021x_das_bounce_port_ignore_get(bool *bounce_port_ignore);
int gnma_ieee8021x_das_disable_port_ignore_set(bool disable_port_ignore);
int gnma_ieee8021x_das_disable_port_ignore_get(bool *disable_port_ignore);
int gnma_ieee8021x_das_ignore_server_key_set(bool ignore_server_key);
int gnma_ieee8021x_das_ignore_server_key_get(bool *ignore_server_key);
int gnma_ieee8021x_das_ignore_session_key_set(bool ignore_session_key);
int gnma_ieee8021x_das_ignore_session_key_get(bool *ignore_session_key);
int gnma_ieee8021x_das_auth_type_key_set(gnma_das_auth_type_t auth_type);
int gnma_ieee8021x_das_auth_type_key_get(gnma_das_auth_type_t *auth_type);
int gnma_ieee8021x_das_dac_hosts_list_get(size_t *list_size,
struct gnma_das_dac_host_key *das_dac_keys_arr);
int gnma_ieee8021x_das_dac_host_add(struct gnma_das_dac_host_key *key,
const char *passkey);
int gnma_ieee8021x_das_dac_host_remove(struct gnma_das_dac_host_key *key);
int
gnma_iee8021x_das_dac_global_stats_get(uint32_t num_of_counters,
gnma_ieee8021x_das_dac_stat_type_t *counter_ids,
uint64_t *counters);
int gnma_radius_hosts_list_get(size_t *list_size,
struct gnma_radius_host_key *hosts_list);
int gnma_radius_host_add(struct gnma_radius_host_key *key, const char *passkey,
uint16_t auth_port, uint8_t prio);
int gnma_radius_host_remove(struct gnma_radius_host_key *key);
int gnma_mac_address_list_get(size_t *list_size, struct gnma_fdb_entry *list);
int gnma_system_password_set(char *password);
int gnma_igmp_snooping_set(uint16_t vid, struct gnma_igmp_snoop_attr *attr);
int gnma_igmp_static_groups_set(uint16_t vid, size_t num_groups,
struct gnma_igmp_static_group_attr *groups);
int gnma_nei_addr_get(struct gnma_port_key *iface, struct in_addr *ip,
char *mac, size_t buf_size);
int gnma_igmp_iface_groups_get(struct gnma_port_key *iface,
char *buf, size_t *buf_size);
struct gnma_change *gnma_change_create(void);
void gnma_change_destory(struct gnma_change *);
int gnma_change_exec(struct gnma_change *);
int gnma_techsupport_start(char *res_path);
int gnma_ip_iface_addr_get(struct gnma_vlan_ip_t *address_list, size_t *list_size);

View File

@@ -0,0 +1,10 @@
all: netlink.a
%.o: %.c
gcc -c -o $@ ${CFLAGS} -I ./ -I/usr/include/libnl3 -lnl-3 -lnl-route-3 $<
netlink.a: netlink_common.o
ar crs $@ $^
netlink.full.a: netlink.a
ar crsT $@ $^

View File

@@ -0,0 +1,220 @@
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <net/if.h>
#include <netlink/netlink.h>
#include <netlink/route/link.h>
#include <netlink/route/route.h>
#include <netlink/route/addr.h>
#include <errno.h>
#include <netlink_common.h>
#define BUFFER_SIZE 4096
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define for_each_nlmsg(n, buf, len) \
for (n = (struct nlmsghdr*)buf; \
NLMSG_OK(n, (uint32_t)len) && n->nlmsg_type != NLMSG_DONE; \
n = NLMSG_NEXT(n, len))
#define for_each_rattr(n, buf, len) \
for (n = (struct rtattr*)buf; RTA_OK(n, len); n = RTA_NEXT(n, len))
static int _nl_connect(int *sock)
{
int s;
s = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (s == -1)
return -1;
*sock = s;
return 0;
}
static void _nl_disconnect(int sock)
{
close(sock);
}
static int _nl_request_ip_send(int sock)
{
struct sockaddr_nl sa = {.nl_family = AF_NETLINK};
char buf[BUFFER_SIZE];
struct ifaddrmsg *ifa;
struct nlmsghdr *nl;
struct msghdr msg;
struct iovec iov;
int res;
memset(&msg, 0, sizeof(msg));
memset(buf, 0, BUFFER_SIZE);
nl = (struct nlmsghdr*)buf;
nl->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg));
nl->nlmsg_type = RTM_GETADDR;
nl->nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT;
iov.iov_base = nl;
iov.iov_len = nl->nlmsg_len;
ifa = (struct ifaddrmsg*)NLMSG_DATA(nl);
ifa->ifa_family = AF_INET; /* IPv4 */
msg.msg_name = &sa;
msg.msg_namelen = sizeof(sa);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
res = sendmsg(sock, &msg, 0);
if (res < 0)
return -1;
return 0;
}
static int _nl_response_get(int sock, void *buf, size_t *len)
{
struct iovec iov = {.iov_base = buf, .iov_len = *len};
struct sockaddr_nl sa = {.nl_family = AF_NETLINK};
struct msghdr msg = {
.msg_name = &sa,
.msg_namelen = sizeof(sa),
.msg_iov = &iov,
.msg_iovlen = 1
};
int res;
res = recvmsg(sock, &msg, 0);
if (res < 0)
return -1;
*len = res;
return 0;
}
static int _nl_iface_addr_parse(uint32_t vid, void *buf, size_t len,
unsigned char prefixlen, struct nl_vid_addr *addr)
{
struct rtattr *rta = NULL;
for_each_rattr(rta, buf, len) {
if (rta->rta_type == IFA_LOCAL) {
memcpy(&addr->address, RTA_DATA(rta), sizeof(addr->address));
addr->vid = vid;
addr->prefixlen = prefixlen;
break;
}
}
return 0;
}
static int _nl_response_addr_parse(void *buf,
size_t len,
struct nl_vid_addr *addr_list,
size_t *list_size)
{
struct ifaddrmsg *iface_addr;
struct nlmsghdr *nl = NULL;
char ifname[IF_NAMESIZE];
size_t num_addrs = 0;
uint32_t vid;
int err = 0;
for_each_nlmsg(nl, buf, len) {
if (nl->nlmsg_type == NLMSG_ERROR)
return -1;
if (nl->nlmsg_type != RTM_NEWADDR) /* only care for addr */
continue;
iface_addr = (struct ifaddrmsg*)NLMSG_DATA(nl);
if (!if_indextoname(iface_addr->ifa_index, ifname))
return -1;
if (sscanf(ifname, "Vlan%u", &vid) != 1)
continue;
if (!addr_list || *list_size == 0) {
num_addrs++;
continue;
}
if (num_addrs > *list_size)
return -EOVERFLOW;
err = _nl_iface_addr_parse(vid, IFA_RTA(iface_addr), IFA_PAYLOAD(nl),
iface_addr->ifa_prefixlen,
&addr_list[num_addrs++]);
if (err)
break;
}
if (num_addrs > *list_size)
err = -EOVERFLOW;
*list_size = num_addrs;
if (err)
return err;
return nl->nlmsg_type == NLMSG_DONE? -ENODATA : 0;
}
int nl_get_ip_list(struct nl_vid_addr *addr_list, size_t *list_size)
{
size_t buf_len = BUFFER_SIZE, batch_size = 0, num_addrs = 0;
char buf[BUFFER_SIZE];
int sock = 0;
int err;
err = _nl_connect(&sock);
if (err)
return err;
err = _nl_request_ip_send(sock);
if (err)
goto out;
while (1) {
err = _nl_response_get(sock, buf, &buf_len);
if (err)
goto out;
err = _nl_response_addr_parse(buf, buf_len, NULL, &batch_size);
if (err == -ENODATA) {
err = 0;
break;
}
if (err && err != -EOVERFLOW) {
goto out;
}
num_addrs += batch_size;
if (!addr_list || *list_size == 0)
continue;
if (num_addrs > *list_size) {
err = -EOVERFLOW;
break;
}
err = _nl_response_addr_parse(buf, buf_len, &addr_list[num_addrs - batch_size], &batch_size);
if (unlikely(err == -ENODATA)) {
err = 0;
break;
}
if (err)
goto out;
}
if (num_addrs > *list_size)
err = -EOVERFLOW;
*list_size = num_addrs;
out:
_nl_disconnect(sock);
return err;
}

View File

@@ -0,0 +1,12 @@
#ifndef _NETLINK_COMMON
#define _NETLINK_COMMON
struct nl_vid_addr {
uint16_t vid;
uint16_t prefixlen;
uint32_t address;
};
int nl_get_ip_list(struct nl_vid_addr *addr_list, size_t *list_size);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
#ifndef _PLAT_REVISION
#define _PLAT_REVISION
#define XSTR(x) STR(x)
#define STR(x) #x
#define PLATFORM_REL_NUM 2.2
#define PLATFORM_BUILD_NUM 5
#ifndef PLATFORM_REVISION
#define PLATFORM_REVISION "Rel " XSTR(PLATFORM_REL_NUM) " build " XSTR(PLATFORM_BUILD_NUM)
#endif
#endif

View File

@@ -2,4 +2,8 @@ plat.a: plat-example.o
ar crs $@ $^
%.o: %.c
ifdef PLATFORM_REVISION
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include -D PLATFORM_REVISION='"$(PLATFORM_REVISION)"' $^
else
gcc -c -o $@ ${CFLAGS} -I ./ -I ../../include $^
endif

View File

@@ -2,6 +2,7 @@
#include <ucentral-platform.h>
#include <ucentral-log.h>
#include <plat-revision.h>
#define UNUSED_PARAM(param) (void)((param))
@@ -12,7 +13,11 @@ int plat_init(void)
int plat_info_get(struct plat_platform_info *info)
{
UNUSED_PARAM(info);
*info = (struct plat_platform_info){0};
snprintf(info->platform, sizeof info->platform, "%s", "Example Platform" );
snprintf(info->hwsku, sizeof info->hwsku, "%s", "example-platform-sku");
snprintf(info->mac, sizeof info->mac, "%s", "24:fe:9a:0f:48:f0");
return 0;
}
@@ -156,10 +161,45 @@ int plat_port_num_get(uint16_t *num_of_active_ports)
UNUSED_PARAM(num_of_active_ports);
return 0;
}
int plat_revision_get(char *str, size_t str_max_len)
{
snprintf(str, str_max_len, PLATFORM_REVISION);
return 0;
}
int plat_reboot_cause_get(struct plat_reboot_cause *cause)
{
UNUSED_PARAM(cause);
return 0;
}
int plat_event_subscribe(const struct plat_event_callbacks *cbs)
{
UNUSED_PARAM(cbs);
return 0;
}
void plat_event_unsubscribe(void)
{
return;
}
int plat_running_img_name_get(char *str, size_t str_max_len)
{
UNUSED_PARAM(str_max_len);
UNUSED_PARAM(str);
return 0;
}
int plat_metrics_save(const struct plat_metrics_cfg *cfg)
{
UNUSED_PARAM(cfg);
return 0;
}
int plat_metrics_restore(struct plat_metrics_cfg *cfg)
{
UNUSED_PARAM(cfg);
return 0;
}
int plat_run_script(struct plat_run_script *p)
{
UNUSED_PARAM(p);
return 0;
}

View File

@@ -0,0 +1,14 @@
#ifndef _PLAT_REVISION
#define _PLAT_REVISION
#define XSTR(x) STR(x)
#define STR(x) #x
#define PLATFORM_REL_NUM 3.2.0
#define PLATFORM_BUILD_NUM 5
#ifndef PLATFORM_REVISION
#define PLATFORM_REVISION "Rel " XSTR(PLATFORM_REL_NUM) " build " XSTR(PLATFORM_BUILD_NUM)
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -70,12 +70,13 @@ int ucentral_router_fib_key_cmp(const struct ucentral_router_fib_key *a,
return 0;
}
/* bool result, as we have no criteria to sort this */
bool ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
const struct ucentral_router_fib_info *b)
int ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
const struct ucentral_router_fib_info *b)
{
if (a->type != b->type)
return false;
if (a->type > b->type)
return 1;
if (a->type < b->type)
return -1;
switch (a->type) {
case UCENTRAL_ROUTE_BLACKHOLE:
@@ -83,24 +84,32 @@ bool ucentral_router_fib_info_cmp(const struct ucentral_router_fib_info *a,
case UCENTRAL_ROUTE_UNREACHABLE:
break;
case UCENTRAL_ROUTE_CONNECTED:
if (a->connected.vid != b->connected.vid)
return false;
if (a->connected.vid > b->connected.vid)
return 1;
if (a->connected.vid < b->connected.vid)
return -1;
break;
case UCENTRAL_ROUTE_BROADCAST:
if (a->broadcast.vid != b->broadcast.vid)
return false;
if (a->broadcast.vid > b->broadcast.vid)
return 1;
if (a->broadcast.vid < b->broadcast.vid)
return -1;
break;
case UCENTRAL_ROUTE_NH:
if (a->nh.vid != b->nh.vid)
return false;
if (a->nh.gw.s_addr != b->nh.gw.s_addr)
return false;
if (a->nh.vid > b->nh.vid)
return 1;
if (a->nh.vid < b->nh.vid)
return -1;
if (a->nh.gw.s_addr > b->nh.gw.s_addr)
return 1;
if (a->nh.gw.s_addr < b->nh.gw.s_addr)
return -1;
break;
default:
break;
}
return true;
return 0;
}
static int __fib_node_key_cmp_cb(const void *a, const void *b)

View File

@@ -22,7 +22,8 @@
#include <cjson/cJSON.h>
#include "ucentral.h"
#include "ucentral-json-parser.h"
/* WA for parser issue */
/* #include "ucentral-json-parser.h" */
#include <openssl/conf.h>
#include <openssl/err.h>
@@ -47,7 +48,6 @@ time_t conn_time;
static int conn_successfull;
struct plat_metrics_cfg ucentral_metrics;
static struct uc_json_parser parser;
static int interrupted;
static pthread_t sigthread;
@@ -67,6 +67,8 @@ lws_protocols protocols[] = {
struct client_config client = {
.redirector_file = "/tmp/ucentral-redirector.json",
.redirector_file_dbg = "/tmp/firstcontact.hdr",
.ols_schema_version_file = "/etc/schema.json",
.ols_client_version_file = "/etc/version.json",
.server = NULL,
.port = 15002,
.path = "/",
@@ -339,6 +341,7 @@ sul_connect_attempt(struct lws_sorted_usec_list *sul)
UC_LOG_DBG("Connected\n");
}
/* WA for parser issue
static void parse_cb(cJSON *j, void *data)
{
(void)data;
@@ -350,6 +353,7 @@ static void parse_error_cb(void *data)
(void)data;
UC_LOG_ERR("JSON config parse failed");
}
*/
static const char *redirector_host_get(void)
{
@@ -424,12 +428,15 @@ callback_broker(struct lws *wsi, enum lws_callback_reasons reason,
websocket = wsi;
connect_send();
conn_successfull = 1;
uc_json_parser_init(&parser, parse_cb, parse_error_cb, 0);
/* WA for parser issue */
/* uc_json_parser_init(&parser, parse_cb, parse_error_cb, 0); */
lws_callback_on_writable(websocket);
break;
case LWS_CALLBACK_CLIENT_RECEIVE:
uc_json_parser_feed(&parser, in, len);
/* WA for parser issue */
/* uc_json_parser_feed(&parser, in, len); */
proto_handle((char *)in);
break;
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
@@ -443,7 +450,8 @@ callback_broker(struct lws *wsi, enum lws_callback_reasons reason,
/* fall through */
case LWS_CALLBACK_CLIENT_CLOSED:
UC_LOG_INFO("connection closed\n");
uc_json_parser_uninit(&parser);
/* WA for parser issue */
/* uc_json_parser_uninit(&parser); */
websocket = NULL;
set_conn_time();
vhd->client_wsi = NULL;
@@ -683,6 +691,57 @@ static void sigthread_create(void)
}
}
static int get_updated_pass(char *pass, size_t *len) {
char *passwd_file_path = "/var/lib/ucentral/admin-cred.buf";
size_t password_size;
int passwd_fd = -1;
char password[64];
if (access(passwd_file_path, F_OK))
goto out;
passwd_fd = open(passwd_file_path, O_RDONLY);
if (passwd_fd < 0) {
UC_LOG_ERR("Failed to open %s", passwd_file_path);
goto out;
}
memset(&password, 0, sizeof(password));
password_size = read(passwd_fd, &password, sizeof(password));
if (password_size == sizeof(password)) {
UC_LOG_ERR("%s is too big", passwd_file_path);
goto out_close;
}
if (!password_size) {
UC_LOG_ERR("failed to read %s", passwd_file_path);
goto out_close;
}
if (*len < password_size) {
UC_LOG_ERR("out buffer is too small (%lu < %lu)",
*len, password_size);
goto out_close;
}
/* remove password from buffer */
close(passwd_fd);
passwd_fd = -1;
if (remove(passwd_file_path)) {
UC_LOG_ERR("Failed to remove %s", passwd_file_path);
goto out;
}
strncpy(pass, password, password_size);
*len = password_size;
return 0;
out_close:
close(passwd_fd);
out:
return -1;
}
int main(void)
{
int logs = LLL_USER | LLL_ERR | LLL_WARN | LLL_NOTICE | LLL_CLIENT;
@@ -693,6 +752,8 @@ int main(void)
struct lws_context_creation_info info = {0};
bool reboot_reason_sent = false;
char *gw_host = NULL;
size_t password_len;
char password[64];
struct stat st;
int ret;
@@ -722,10 +783,10 @@ int main(void)
UC_LOG_CRIT("Platform initialization failed");
}
plat_running_img_name_get(client.firmware, sizeof(client.firmware));
plat_revision_get(client.firmware, sizeof(client.firmware));
if ((gw_host = getenv("UC_GATEWAY_ADDRESS"))) {
gw_host = strdup(gw_host);
client.server = strdup(gw_host);
} else {
while (1) {
if (uc_loop_interrupted_get())
@@ -770,13 +831,20 @@ int main(void)
}
sigthread_context_set(context);
password_len = sizeof(password);
if (get_updated_pass(password, &password_len))
password_len = 0;
proto_start();
while (!uc_loop_interrupted_get()) {
lws_service_tsi(context, 0, 0);
if (conn_successfull) {
deviceupdate_send();
if (password_len) {
deviceupdate_send(password);
password_len = 0;
}
if (!reboot_reason_sent) {
device_rebootcause_send();
reboot_reason_sent = true;

View File

@@ -41,6 +41,8 @@ extern "C" {
struct client_config {
const char *redirector_file;
const char *redirector_file_dbg;
const char *ols_client_version_file;
const char *ols_schema_version_file;
const char *server;
int16_t port;
const char *path;
@@ -60,14 +62,14 @@ extern time_t conn_time;
extern struct plat_metrics_cfg ucentral_metrics;
/* proto.c */
void proto_handle(cJSON *cmd);
void proto_handle(char *cmd);
void proto_cb_register_uc_send_msg(uc_send_msg_cb cb);
void proto_cb_register_uc_connect_msg_send(uc_send_connect_msg_cb cb);
void connect_send(void);
void ping_send(void);
void health_send(struct plat_health_info *);
void state_send(struct plat_state_info *plat_state_info);
void deviceupdate_send(void);
void deviceupdate_send(const char *updated_pass);
void device_rebootcause_send(void);
void telemetry_send(struct plat_state_info *plat_state_info);
void log_send(const char *message, int severity);

5
version.json Normal file
View File

@@ -0,0 +1,5 @@
{
"major": 3,
"minor": 2,
"patch": 7
}