Skip to content

Commit

Permalink
vxlan: advertise netns of vxlan dev in fdb msg
Browse files Browse the repository at this point in the history
Netlink FDB messages are sent in the link netns. The header of these messages
contains the ifindex (ndm_ifindex) of the netdevice, but this ifindex is
unusable in case of x-netns vxlan.
I named the new attribute NDA_NDM_IFINDEX_NETNSID, to avoid confusion with
NDA_IFINDEX.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nicolas Dichtel authored and David S. Miller committed Jan 24, 2015
1 parent e5f4e7b commit 193523b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
ndm->ndm_flags = fdb->flags;
ndm->ndm_type = RTN_UNICAST;

if (!net_eq(dev_net(vxlan->dev), vxlan->net) &&
nla_put_s32(skb, NDA_NDM_IFINDEX_NETNSID,
peernet2id(vxlan->net, dev_net(vxlan->dev))))
goto nla_put_failure;

if (send_eth && nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->eth_addr))
goto nla_put_failure;

Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/neighbour.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum {
NDA_VNI,
NDA_IFINDEX,
NDA_MASTER,
NDA_NDM_IFINDEX_NETNSID,
__NDA_MAX
};

Expand Down
1 change: 1 addition & 0 deletions net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ int peernet2id(struct net *net, struct net *peer)

return id >= 0 ? id : NETNSA_NSID_NOT_ASSIGNED;
}
EXPORT_SYMBOL(peernet2id);

struct net *get_net_ns_by_id(struct net *net, int id)
{
Expand Down

0 comments on commit 193523b

Please sign in to comment.