troglobit

libnl::l_af_ops

Apr 26th, 2022 (edited)
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.83 KB | None | 0 0
  1. diff --git a/lib/route/link.c b/lib/route/link.c
  2. index 6d76395..78e860d 100644
  3. --- a/lib/route/link.c
  4. +++ b/lib/route/link.c
  5. @@ -309,6 +309,7 @@ static int link_clone(struct nl_object *_dst, struct nl_object *_src)
  6.     memset(dst->l_af_data, 0, sizeof (dst->l_af_data));
  7.     dst->l_info = NULL;
  8.     dst->l_ifalias = NULL;
  9. +   dst->l_af_ops = NULL;
  10.     dst->l_phys_port_id = NULL;
  11.     dst->l_phys_switch_id = NULL;
  12.     dst->l_vf_list = NULL;
  13. @@ -345,6 +346,9 @@ static int link_clone(struct nl_object *_dst, struct nl_object *_src)
  14.         }
  15.     }
  16.  
  17. +   /* Create matching l_af_ops in clone */
  18. +   rtnl_link_set_family(dst, src->l_family);
  19. +
  20.     if ((err = do_foreach_af(src, af_clone, dst)) < 0)
  21.         return err;
  22.  
  23. @@ -608,7 +612,7 @@ static int __link_msg_parser(struct nlmsghdr *n, struct nl_parser_param *pp,
  24.     struct nla_policy *link_policy = rtln_link_policy;
  25.     struct ifinfomsg *ifi;
  26.     struct nlattr *tb[IFLA_MAX+1];
  27. -   int err, family;
  28. +   int err;
  29.  
  30.     link = rtnl_link_alloc();
  31.     if (link == NULL)
  32. @@ -620,16 +624,15 @@ static int __link_msg_parser(struct nlmsghdr *n, struct nl_parser_param *pp,
  33.         return -NLE_MSG_TOOSHORT;
  34.  
  35.     ifi = nlmsg_data(n);
  36. -   link->l_family = family = ifi->ifi_family;
  37.     link->l_arptype = ifi->ifi_type;
  38.     link->l_index = ifi->ifi_index;
  39.     link->l_flags = ifi->ifi_flags;
  40.     link->l_change = ifi->ifi_change;
  41. -   link->ce_mask = (LINK_ATTR_FAMILY |
  42. -            LINK_ATTR_ARPTYPE| LINK_ATTR_IFINDEX |
  43. +   link->ce_mask = (LINK_ATTR_ARPTYPE| LINK_ATTR_IFINDEX |
  44.              LINK_ATTR_FLAGS | LINK_ATTR_CHANGE);
  45.  
  46. -   if ((link->l_af_ops = af_lookup_and_alloc(link, family))) {
  47. +   rtnl_link_set_family(link, ifi->ifi_family);
  48. +   if (link->l_af_ops) {
  49.         if (link->l_af_ops->ao_protinfo_policy) {
  50.             _NL_STATIC_ASSERT (sizeof(rtln_link_policy) == sizeof(real_link_policy));
  51.             memcpy(&real_link_policy, rtln_link_policy, sizeof(rtln_link_policy));
  52.  
Add Comment
Please, Sign In to add comment