--- zzzz-none-000/linux-5.15.111/net/bridge/br_input.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-arm-6670-761/linux-5.15.111/net/bridge/br_input.c 2024-02-07 09:28:09.000000000 +0000 @@ -6,6 +6,15 @@ * Authors: * Lennert Buytenhek */ +/* + Includes Intel Corporation's changes/modifications dated: [Dec.2013]. + Changed/modified portions - Copyright © 2013, Intel Corporation + 1. WARN on NULL pointer in br_handle_frame() + + Includes Intel Corporation's changes/modifications dated: [May.2014]. + Changed/modified portions - Copyright © 2014, Intel Corporation + 2. Skip Link Local spacial proccess for L2VPN packets in br_handle_frame() +*/ #include #include @@ -23,6 +32,14 @@ #include "br_private.h" #include "br_private_tunnel.h" +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER +extern int ti_selective_packet_handler (struct sk_buff *skb); +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ + +#ifdef CONFIG_INTEL_L2VPN_L2CP_FORWARD +extern int intel_l2vpn_packet_handler (struct sk_buff *skb, int *l2vpnRelate); +#endif /* CONFIG_INTEL_L2VPN_L2CP_FORWARD */ + static int br_netif_receive_skb(struct net *net, struct sock *sk, struct sk_buff *skb) { @@ -97,8 +114,28 @@ nbp_switchdev_frame_mark(p, skb); - /* insert into forwarding database after filtering to avoid spoofing */ br = p->br; + +#ifdef CONFIG_BRIDGE_NETFILTER +#ifdef CONFIG_BRIDGE_EBT_FORWARD + /* Check for predetermined forwarding ebtables rule */ + if (skb->bridge_forward_port) { + BR_INPUT_SKB_CB(skb)->brdev = br->dev; + local_rcv = !!(br->dev->flags & IFF_PROMISC); + br_forward(skb->bridge_forward_port, skb, local_rcv, false); + if (local_rcv) { + /* Forward the frame and send a copy to the bridge interface */ + return br_pass_frame_up(skb); + } + else { + /* Forward packet only to destination port */ + goto out; + } + } +#endif +#endif + + /* insert into forwarding database after filtering to avoid spoofing */ if (p->flags & BR_LEARNING) br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, 0); @@ -140,6 +177,12 @@ switch (pkt_type) { case BR_PKT_MULTICAST: +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER + /* If return value is zero indicates fall back to default behavior */ + if (ti_selective_packet_handler(skb) != 0) { + goto out; + } +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ mdst = br_mdb_get(brmctx, skb, vid); if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) && br_multicast_querier_exists(brmctx, eth_hdr(skb), mdst)) { @@ -171,6 +214,12 @@ dst->used = now; br_forward(dst->dst, skb, local_rcv, false); } else { +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER + /* If return value is zero indicates fall back to default behavior */ + if (ti_selective_packet_handler(skb) != 0) { + goto out; + } +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ if (!mcast_hit) br_flood(br, skb, pkt_type, local_rcv, false); else @@ -288,6 +337,11 @@ struct sk_buff *skb = *pskb; const unsigned char *dest = eth_hdr(skb)->h_dest; +#ifdef CONFIG_INTEL_L2VPN_L2CP_FORWARD + int l2vpnRelated = 0; +#endif /* CONFIG_INTEL_L2VPN_L2CP_FORWARD */ + + if (unlikely(skb->pkt_type == PACKET_LOOPBACK)) return RX_HANDLER_PASS; @@ -299,14 +353,38 @@ return RX_HANDLER_CONSUMED; memset(skb->cb, 0, sizeof(struct br_input_skb_cb)); + /*this cond was added for skb->ti_selective_forward will receive later on the correct vlan device*/ +#ifdef CONFIG_TI_DOCSIS_INPUT_DEV + if(!skb->ti_docsis_input_dev) { + skb->ti_docsis_input_dev = skb->dev; + } +#endif p = br_port_get_rcu(skb->dev); if (p->flags & BR_VLAN_TUNNEL) br_handle_ingress_vlan_tunnel(skb, p, nbp_vlan_group_rcu(p)); + if (WARN(p == NULL, "%s - %d: br_port_get_rcu(skb->dev) returned NULL, dropping packet (dev == %s)", + __func__, __LINE__, skb->dev ? skb->dev->name : "NULL")) + { + /* Cannot continue since the following lines require p != NULL */ + /* What should we do with this packet???? */ + goto drop; + } + if (unlikely(is_link_local_ether_addr(dest))) { u16 fwd_mask = p->br->group_fwd_mask_required; - +#ifdef CONFIG_INTEL_L2VPN_L2CP_FORWARD + /* Check if the packet is L2VPN related. If so, skip link local special proccess. */ + /* Upstream L2VPN packets will be handle Link Local packets in Docsis Bridge */ + if (!intel_l2vpn_packet_handler(skb, &l2vpnRelated)) + { + if (l2vpnRelated) + { + goto forward; + } + } +#endif /* CONFIG_INTEL_L2VPN_L2CP_FORWARD */ /* * See IEEE 802.1D Table 7-10 Reserved addresses * @@ -373,6 +451,12 @@ case BR_STATE_LEARNING: if (ether_addr_equal(p->br->dev->dev_addr, dest)) skb->pkt_type = PACKET_HOST; +#ifdef CONFIG_BRIDGE_NETFILTER +#ifdef CONFIG_BRIDGE_EBT_FORWARD + /* Initialize bridge bridge_forward_port so prerouting rule can populate it */ + skb->bridge_forward_port = NULL; +#endif +#endif return nf_hook_bridge_pre(skb, pskb); default: