--- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -29,6 +29,20 @@ #include #include +ATOMIC_NOTIFIER_HEAD(vxlan_fdb_notifier_list); + +void vxlan_fdb_register_notify(struct notifier_block *nb) +{ + atomic_notifier_chain_register(&vxlan_fdb_notifier_list, nb); +} +EXPORT_SYMBOL(vxlan_fdb_register_notify); + +void vxlan_fdb_unregister_notify(struct notifier_block *nb) +{ + atomic_notifier_chain_unregister(&vxlan_fdb_notifier_list, nb); +} +EXPORT_SYMBOL(vxlan_fdb_unregister_notify); + #if IS_ENABLED(CONFIG_IPV6) #include #include @@ -260,6 +274,7 @@ static void __vxlan_fdb_notify(struct vx { struct net *net = dev_net(vxlan->dev); struct sk_buff *skb; + struct vxlan_fdb_event vfe; int err = -ENOBUFS; skb = nlmsg_new(vxlan_nlmsg_size(), GFP_ATOMIC); @@ -275,6 +290,10 @@ static void __vxlan_fdb_notify(struct vx } rtnl_notify(skb, net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC); + vfe.dev = vxlan->dev; + vfe.rdst = rd; + ether_addr_copy(vfe.eth_addr, fdb->eth_addr); + atomic_notifier_call_chain(&vxlan_fdb_notifier_list, type, (void *)&vfe); return; errout: if (err < 0) @@ -441,6 +460,18 @@ static struct vxlan_fdb *vxlan_find_mac( return f; } +/* Find and update age of fdb entry corresponding to MAC. */ +void vxlan_fdb_update_mac(struct vxlan_dev *vxlan, const u8 *mac, uint32_t vni) +{ + u32 hash_index; + + hash_index = fdb_head_index(vxlan, mac, vni); + spin_lock_bh(&vxlan->hash_lock[hash_index]); + vxlan_find_mac(vxlan, mac, vni); + spin_unlock_bh(&vxlan->hash_lock[hash_index]); +} +EXPORT_SYMBOL(vxlan_fdb_update_mac); + /* caller should hold vxlan->hash_lock */ static struct vxlan_rdst *vxlan_fdb_find_rdst(struct vxlan_fdb *f, union vxlan_addr *ip, __be16 port, @@ -2581,6 +2612,9 @@ void vxlan_xmit_one(struct sk_buff *skb, goto out_unlock; } + /* Reset the skb_iif to Tunnels interface index */ + skb->skb_iif = dev->ifindex; + tos = ip_tunnel_ecn_encap(tos, old_iph, skb); ttl = ttl ? : ip4_dst_hoplimit(&rt->dst); err = vxlan_build_skb(skb, ndst, sizeof(struct iphdr), @@ -2652,6 +2686,9 @@ void vxlan_xmit_one(struct sk_buff *skb, if (err < 0) goto tx_error; + /* Reset the skb_iif to Tunnels interface index */ + skb->skb_iif = dev->ifindex; + udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev, &local_ip.sin6.sin6_addr, &dst->sin6.sin6_addr, tos, ttl, --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -352,6 +352,19 @@ struct vxlan_dev { VXLAN_F_VNIFILTER | \ VXLAN_F_LOCALBYPASS) +/* + * Application data for fdb notifier event + */ +struct vxlan_fdb_event { + struct net_device *dev; + struct vxlan_rdst *rdst; + u8 eth_addr[ETH_ALEN]; +}; + +extern void vxlan_fdb_register_notify(struct notifier_block *nb); +extern void vxlan_fdb_unregister_notify(struct notifier_block *nb); +extern void vxlan_fdb_update_mac(struct vxlan_dev *vxlan, const u8 *mac, uint32_t vni); + struct net_device *vxlan_dev_create(struct net *net, const char *name, u8 name_assign_type, struct vxlan_config *conf);