--- zzzz-none-000/linux-5.4.213/drivers/net/vxlan.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/drivers/net/vxlan.c 2024-05-29 11:19:55.000000000 +0000 @@ -85,6 +85,20 @@ /* salt for hash table */ static u32 vxlan_salt __read_mostly; +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 || @@ -335,6 +349,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); @@ -350,6 +365,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) @@ -516,6 +535,18 @@ 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, @@ -2552,6 +2583,9 @@ ndst = &rt->dst; skb_tunnel_check_pmtu(skb, ndst, VXLAN_HEADROOM); + /* 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), @@ -2600,6 +2634,9 @@ 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,