--- zzzz-none-000/linux-4.9.279/net/bridge/br_input.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-arm-6591-750/linux-4.9.279/net/bridge/br_input.c 2023-02-08 10:58:16.000000000 +0000 @@ -10,6 +10,15 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ +/* + 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 @@ -22,6 +31,15 @@ #include #include "br_private.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 */ + + /* Hook for brouter */ br_should_route_hook_t __rcu *br_should_route_hook __read_mostly; EXPORT_SYMBOL(br_should_route_hook); @@ -146,8 +164,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, false); @@ -174,6 +212,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(br, skb, vid); if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) && br_multicast_querier_exists(br, eth_hdr(skb))) { @@ -201,6 +245,12 @@ dst->used = jiffies; 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 @@ -248,6 +298,11 @@ const unsigned char *dest = eth_hdr(skb)->h_dest; br_should_route_hook_t *rhook; +#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; @@ -258,11 +313,36 @@ if (!skb) return RX_HANDLER_CONSUMED; + /*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 (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 * @@ -334,6 +414,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 NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, dev_net(skb->dev), NULL, skb, skb->dev, NULL,