From: Igor Putovny Date: Fri, 1 Aug 2025 11:55:57 +0000 (+0200) Subject: Add parsing of netlink attributes of bridge device X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41f4e3724a3edaa0c86d450dd52f2b9d396cabe9;p=thirdparty%2Fbird.git Add parsing of netlink attributes of bridge device --- diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index d649fe600..555f6a38e 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -390,6 +390,12 @@ static struct nl_want_attrs ifla_vxlan_attr_want[BIRD_IFLA_VXLAN_MAX] = { [IFLA_VXLAN_LOCAL6] = { 1, 1, sizeof(ip6_addr) }, }; +#define BIRD_IFLA_BR_MAX (IFLA_BR_VLAN_FILTERING+1) + +static struct nl_want_attrs ifla_br_attr_want[BIRD_IFLA_BR_MAX] = { + [IFLA_BR_VLAN_FILTERING] = { 1, 1, sizeof(u8) }, +}; + #define BIRD_IFA_MAX (IFA_FLAGS+1) static struct nl_want_attrs ifa_attr_want4[BIRD_IFA_MAX] = { @@ -1028,6 +1034,21 @@ nl_parse_link(struct nlmsghdr *h, int scan) ea_set_attr_data(&f.attrs->eattrs, tmp_linpool, EA_IFACE_VXLAN_IP_ADDR, 0, EAF_TYPE_IP_ADDRESS, &addr, sizeof(addr)); } } + else if (!strcmp(kind, "bridge") && li[IFLA_INFO_DATA]) + { + struct rtattr *data[BIRD_IFLA_BR_MAX]; + nl_attr_len = RTA_PAYLOAD(li[IFLA_INFO_DATA]); + nl_parse_attrs(RTA_DATA(li[IFLA_INFO_DATA]), ifla_br_attr_want, data, sizeof(data)); + + /* Save device type (bridge) into attributes */ + ea_set_attr_u32(&f.attrs->eattrs, tmp_linpool, EA_IFACE_BRIDGE_TYPE, 0, EAF_TYPE_INT, IFACE_TYPE_BRIDGE); + + if (data[IFLA_BR_VLAN_FILTERING]) + { + u8 vlan_filtering = rta_get_u32(data[IFLA_BR_VLAN_FILTERING]); + ea_set_attr_u32(&f.attrs->eattrs, tmp_linpool, EA_IFACE_BRIDGE_VLAN_FILTERING, 0, EAF_TYPE_INT, vlan_filtering); + } + } } ifi = if_find_by_index(i->ifi_index); diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index 7c5ea3f1b..58ac7e052 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -37,6 +37,10 @@ struct kif_proto; #define EA_IFACE_VXLAN_LEARNING EA_CODE(PROTOCOL_DEVICE, 2) #define EA_IFACE_VXLAN_IP_ADDR EA_CODE(PROTOCOL_DEVICE, 3) +#define EA_IFACE_BRIDGE_TYPE EA_CODE(PROTOCOL_DEVICE, 0) +#define EA_IFACE_BRIDGE_NAME EA_CODE(PROTOCOL_DEVICE, 1) +#define EA_IFACE_BRIDGE_VLAN_FILTERING EA_CODE(PROTOCOL_DEVICE, 2) + /* Whenever we recognize our own routes, we allow learing of foreign routes */ #ifdef CONFIG_SELF_CONSCIOUS