diff options
author | wangli09 <wangli09@kuaishou.com> | 2020-08-08 10:52:31 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-03-09 09:45:12 (GMT) |
commit | d0cf3a971246b691d068b75cc3b814c01150dba3 (patch) | |
tree | 907ad92b2e0d7e5aa24fa46545eff0c761f3670d /lib/route | |
parent | 3bf0a9c211b5e22d805632541d1e5c07e6134922 (diff) | |
download | libnl-d0cf3a971246b691d068b75cc3b814c01150dba3.zip libnl-d0cf3a971246b691d068b75cc3b814c01150dba3.tar.gz libnl-d0cf3a971246b691d068b75cc3b814c01150dba3.tar.bz2 |
neigh: support to add fdb entry
rtnl_neigh.n_family should be set as AF_BRIDGE when we want to add a fdb entry,
but the func build_neigh_msg does not allow dst addr to be put at that time.
Here is the example:
struct rtnl_neigh *neigh = rtnl_neigh_alloc();
struct nl_addr *mac = nl_addr_build(AF_LLC, eth, ETH_ALEN);
struct nl_addr *dst = nl_addr_build(AF_INET, addr, 4);
rtnl_neigh_set_ifindex(neigh, rtnl_link_get_ifindex(vxlan_link));
rtnl_neigh_set_state(neigh, NUD_NOARP | NUD_PERMANENT);
rtnl_neigh_set_lladdr(neigh, mac);
rtnl_neigh_set_flags(neigh, NTF_SELF);
rtnl_neigh_set_dst(neigh, dst);
rtnl_neigh_set_family(neigh, AF_BRIDGE);
rtnl_neigh_add(sk, neigh, NLM_F_CREATE);
Then command "bridge fdb show" will print out the fdb entry:
02:68:60:19:6b:a4 dev flannel.1 dst 10.40.252.12 self permanent
Signed-off-by: huangxuesen <huangxuesen@kuaishou.com>
Signed-off-by: wangli09 <wangli09@kuaishou.com>
https://github.com/thom311/libnl/pull/260
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/neigh.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/route/neigh.c b/lib/route/neigh.c index 048670f..da2b0da 100644 --- a/lib/route/neigh.c +++ b/lib/route/neigh.c @@ -709,7 +709,7 @@ static int build_neigh_msg(struct rtnl_neigh *tmpl, int cmd, int flags, if (nlmsg_append(msg, &nhdr, sizeof(nhdr), NLMSG_ALIGNTO) < 0) goto nla_put_failure; - if (tmpl->n_family != AF_BRIDGE) + if (tmpl->ce_mask & NEIGH_ATTR_DST) NLA_PUT_ADDR(msg, NDA_DST, tmpl->n_dst); if (tmpl->ce_mask & NEIGH_ATTR_LLADDR) |