Skip to content

Commit

Permalink
confd: use the system base mac as mac address on bridges
Browse files Browse the repository at this point in the history
To prevent the kernel from setting a random mac address on new bridges,
before we have added any bridge ports, we create bridges using the:

  1. Custom mac address from the configuration (phys-address)
  2. System base mac from /run/system.json
  3. None, if there is no base mac address in system.json, e.g. r2s

Fixes #357

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
  • Loading branch information
troglobit committed Apr 25, 2024
1 parent 23668c7 commit 68f036a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
7 changes: 6 additions & 1 deletion doc/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Change Log
All notable changes to the project are documented in this file.


[v24.03.0][UNRELEASED]
[v24.04.0][UNRELEASED]
-------------------------

Please note, as of this release the Infix Classic variant has been
Expand Down Expand Up @@ -63,6 +63,10 @@ separate project. Going forward Infix' focus is entirely on NETCONF.
- Fix #328: when setting up a VLAN filtering bridge, the PVID for bridge
ports defaulted to 1, making it impossible to set up "tagged-only"
ports which drop ingressing untagged traffic
- Fix #357: EUI-64 based IPv6 autoconf address on bridges seem to be
randomized. Problem caused by kernel setting a random MAC before any
bridge port is added. Fixed by using the device's base MAC address on
bridge interfaces. Possible to override using `phys-address` option
- Fix #358: MAC address no longer shown for bridge interfaces in CLI
`show interfaces` command
- Fix #366: static routes from container host interfaces do not work.
Expand Down Expand Up @@ -771,6 +775,7 @@ Supported YANG models in addition to those used by sysrepo and netopeer:

[buildroot]: https://buildroot.org/
[UNRELEASED]: https://github.com/kernelkit/infix/compare/v24.02.0...HEAD
[v24.04.0]: https://github.com/kernelkit/infix/compare/v24.02.0...v24.04.0
[v24.02.0]: https://github.com/kernelkit/infix/compare/v23.11.0...v24.02.0
[v23.11.0]: https://github.com/kernelkit/infix/compare/v23.10.0...v23.11.0
[v23.10.0]: https://github.com/kernelkit/infix/compare/v23.09.0...v23.10.0
Expand Down
2 changes: 1 addition & 1 deletion src/confd/src/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "core.h"

static struct confd confd;
struct confd confd;

uint32_t core_hook_prio(void)
{
Expand Down
3 changes: 3 additions & 0 deletions src/confd/src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#define CB_PRIO_PRIMARY 65535
#define CB_PRIO_PASSIVE 65000

extern struct confd confd;


static inline void print_val(sr_val_t *val)
{
char *str;
Expand Down
26 changes: 24 additions & 2 deletions src/confd/src/ietf-interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,15 +1238,37 @@ static int netdag_gen_bridge(sr_session_ctx_t *session, struct dagger *net, stru
vlan_filtering = bridge_vlan_settings(cif, &proto, &vlan_mcast);
fwd_mask = bridge_fwd_mask(cif);

fprintf(ip, "link %s dev %s", op, brname);
/*
* Must set base mac on add to prevent kernel from seeding ipv6
* addrgenmode eui64 with random mac, issue #357.
*/
if (add) {
const char *mac;

mac = lydx_get_cattr(cif, "phys-address");
if (!mac) {
struct json_t *j;

j = json_object_get(confd.root, "mac-address");
if (j)
mac = json_string_value(j);
}
if (mac)
fprintf(ip, " address %s", mac);

/* on failure, fall back to kernel's random mac */
}

/*
* Issue #198: we require explicit VLAN assignment for ports
* when VLAN filtering is enabled. We strongly
* believe this is the only sane way of doing it.
* Issue #310: malplaced 'vlan_default_pvid 0'
*/
fprintf(ip, "link %s dev %s type bridge group_fwd_mask %d mcast_flood_always 1"
fprintf(ip, " type bridge group_fwd_mask %d mcast_flood_always 1"
" vlan_filtering %d vlan_default_pvid 0",
op, brname, fwd_mask, vlan_filtering ? 1 : 0);
fwd_mask, vlan_filtering ? 1 : 0);

if ((err = bridge_mcast_settings(ip, brname, cif, vlan_mcast)))
goto out;
Expand Down

0 comments on commit 68f036a

Please sign in to comment.