]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Add attributes to interface structures
authorIgor Putovny <igor.putovny@nic.cz>
Tue, 29 Jul 2025 13:28:17 +0000 (15:28 +0200)
committerMaria Matejka <mq@ucw.cz>
Wed, 13 May 2026 10:03:00 +0000 (12:03 +0200)
nest/iface.c
nest/iface.h
sysdep/linux/netlink.c

index a91f4ecf39873c36dc875f71345ddc845f983cbd..8f6caafbba18fac2a83bad62e21b3e415cf3178c 100644 (file)
@@ -130,6 +130,8 @@ if_what_changed(struct iface *i, struct iface *j)
     c |= IF_CHANGE_LINK;
   if (i->mtu != j->mtu)
     c |= IF_CHANGE_MTU;
+  if (i->attrs != j->attrs)
+    c |= IF_CHANGE_ATTRS;
   return c;
 }
 
@@ -140,6 +142,7 @@ if_copy(struct iface *to, struct iface *from)
   to->mtu = from->mtu;
   to->master_index = from->master_index;
   to->master = from->master;
+  to->attrs = from->attrs;
 }
 
 static inline void
@@ -301,6 +304,9 @@ if_update(struct iface *new)
   struct iface *i;
   unsigned c;
 
+  if (new->attrs && !rta_is_cached(new->attrs))
+    new->attrs = new->attrs->eattrs ? rta_lookup(new->attrs) : NULL;
+
   WALK_LIST(i, iface_list)
     if (!strcmp(new->name, i->name))
       {
@@ -316,11 +322,13 @@ if_update(struct iface *new)
            new->llv6 = i->llv6;
            new->sysdep = i->sysdep;
            memcpy(&new->addrs, &i->addrs, sizeof(i->addrs));
+           rta_free(i->attrs);
            memcpy(i, new, sizeof(*i));
            i->flags &= ~IF_UP;         /* IF_TMP_DOWN will be added later */
            goto newif;
          }
 
+       rta_free(i->attrs);
        if_copy(i, new);
        if (c)
          if_notify_change(c, i);
index 66af3d9183a3dfc3650058db4a6edbe5a9bcfd20..b00b42482d3dcddf61e4d3784c33e1bda666b27e 100644 (file)
@@ -42,6 +42,7 @@ struct iface {
   struct ifa *llv6;                    /* Primary link-local address for IPv6 */
   ip4_addr sysdep;                     /* Arbitrary IPv4 address for internal sysdep use */
   list neighbors;                      /* All neighbors on this interface */
+  struct rta *attrs;
 };
 
 #define IF_UP 1                                /* Currently just IF_ADMIN_UP */
@@ -95,6 +96,7 @@ struct iface {
 #define IF_CHANGE_ADDR6        0x200           /* ... */
 #define IF_CHANGE_LLV6 0x400
 #define IF_CHANGE_SYSDEP 0x800
+#define IF_CHANGE_ATTRS 0x1000
 #define IF_CHANGE_TOO_MUCH 0x40000000  /* Used internally */
 
 #define IF_CHANGE_UPDOWN (IF_CHANGE_UP | IF_CHANGE_DOWN)
index 8be5112c462b7b754b0cf365b9072eff9a36e1d4..12e9683274d60174f1034081988402d87f9e7ee2 100644 (file)
@@ -907,7 +907,8 @@ nl_parse_link(struct nlmsghdr *h, int scan)
   struct ifinfomsg *i;
   struct rtattr *a[BIRD_IFLA_MAX];
   int new = h->nlmsg_type == RTM_NEWLINK;
-  struct iface f = {};
+  struct rta rta = { 0 };
+  struct iface f = { .attrs = &rta };
   struct iface *ifi;
   const char *name, *kind = NULL;
   u32 mtu, master = 0;