]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Add parsing of netlink attributes of bridge device
authorIgor Putovny <igor.putovny@nic.cz>
Fri, 1 Aug 2025 11:55:57 +0000 (13:55 +0200)
committerIgor Putovny <igor.putovny@nic.cz>
Fri, 1 Aug 2025 13:24:02 +0000 (15:24 +0200)
sysdep/linux/netlink.c
sysdep/unix/krt.h

index d649fe600bf1b7e850f8730821092a39cf492553..555f6a38e4b731ad5563f47aa4cba5093ebee167 100644 (file)
@@ -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);
index 7c5ea3f1b10d60a30def34fd10d4f93258fe62ae..58ac7e05283e3b942ee39579366d12a62be09de1 100644 (file)
@@ -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