--- zzzz-none-000/linux-4.4.271/drivers/net/vxlan.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/drivers/net/vxlan.c 2023-04-19 10:22:29.000000000 +0000 @@ -102,6 +102,20 @@ static u32 vxlan_salt __read_mostly; static struct workqueue_struct *vxlan_wq; +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); + static inline bool vxlan_collect_metadata(struct vxlan_sock *vs) { return vs->flags & VXLAN_F_COLLECT_METADATA || @@ -356,6 +370,7 @@ { 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); @@ -371,6 +386,10 @@ } 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) @@ -451,6 +470,15 @@ return f; } +/* Find and update age of fdb entry corresponding to MAC. */ +void vxlan_fdb_update_mac(struct vxlan_dev *vxlan, const u8 *mac) +{ + spin_lock_bh(&vxlan->hash_lock); + vxlan_find_mac(vxlan, mac); + spin_unlock_bh(&vxlan->hash_lock); +} +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, @@ -1780,6 +1808,9 @@ skb_set_inner_protocol(skb, htons(ETH_P_TEB)); + /* Reset the skb_iif to Tunnels interface index */ + skb->skb_iif = dev->ifindex; + udp_tunnel6_xmit_skb(dst, sk, skb, dev, saddr, daddr, prio, ttl, src_port, dst_port, !!(vxflags & VXLAN_F_UDP_ZERO_CSUM6_TX)); @@ -2074,6 +2105,9 @@ return; } + /* 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_xmit_skb(rt, sk, skb, fl4.saddr, @@ -2560,7 +2594,7 @@ } spin_unlock(&vn->sock_lock); } -EXPORT_SYMBOL_GPL(vxlan_get_rx_port); +EXPORT_SYMBOL(vxlan_get_rx_port); /* Initialize the device structure. */ static void vxlan_setup(struct net_device *dev) @@ -3232,7 +3266,7 @@ return dev; } -EXPORT_SYMBOL_GPL(vxlan_dev_create); +EXPORT_SYMBOL(vxlan_dev_create); static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn, struct net_device *dev)