--- zzzz-none-000/linux-4.9.279/net/ipv4/ip_output.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-atom-6591-750/linux-4.9.279/net/ipv4/ip_output.c 2023-02-08 11:43:43.000000000 +0000 @@ -42,6 +42,10 @@ * Hirokazu Takahashi: sendfile() on UDP works now. */ +/* + * Includes Intel Corporation's changes/modifications dated: 2018. + * Changed/modified portions - Copyright (c) 2018, Intel Corporation. + */ #include #include #include @@ -81,6 +85,27 @@ #include #include +#include + +#if PUMA7_OR_NEWER_SOC_TYPE +# ifdef CONFIG_ARM_AVALANCHE_SOC +# include +# else +# include +# endif +#endif + +#ifdef CONFIG_TI_DOCSIS_INPUT_DEV +# define DBRIDGE_IFINDEX_CHK(__ifindex, format, args...) \ +{ \ + if (((__ifindex) < 0) || ((__ifindex) >= TI_MAX_DEVICE_INDEX)) \ + { \ + printk("\n===>>> %s - %d: Currupt " #__ifindex " - %d\n" format, __func__, __LINE__, __ifindex, ##args); \ + BUG(); \ + } \ +} +#endif + static int ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, unsigned int mtu, @@ -110,6 +135,18 @@ skb->protocol = htons(ETH_P_IP); + if (avm_pa_dev_local_out(AVM_PA_NET_IP_DEVINFO(net), skb) == AVM_PA_RX_STOLEN) + return 0; + +#ifdef CONFIG_TI_ICMP_ECHO_REPLY_NETFILTER_BYPASS + if(iph->protocol == IPPROTO_ICMP) { + struct icmphdr *icmph = (struct icmphdr *)((unsigned char *)(iph)+iph->ihl*4); + if(icmph->type == ICMP_ECHOREPLY) { + return 1; + } + } +#endif /* CONFIG_TI_ICMP_ECHO_REPLY_NETFILTER_BYPASS */ + return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, net, sk, skb, NULL, skb_dst(skb)->dev, dst_output); @@ -188,6 +225,11 @@ unsigned int hh_len = LL_RESERVED_SPACE(dev); struct neighbour *neigh; u32 nexthop; +#ifdef CONFIG_TI_PACKET_PROCESSOR +# if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) + const struct nf_conn *ct; +# endif +#endif if (rt->rt_type == RTN_MULTICAST) { IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTMCAST, skb->len); @@ -209,6 +251,16 @@ skb = skb2; } +#ifdef CONFIG_TI_PACKET_PROCESSOR +# if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) + ct = (struct nf_conn *)skb->nfct; + if (ct != NULL) + { + ti_hil_pp_event( TI_CT_NETFILTER_CANCEL_DISCARD_ACCELERATION, (void *)ct ); + } +# endif +#endif + if (lwtunnel_xmit_redirect(dst->lwtstate)) { int res = lwtunnel_xmit(skb); @@ -507,10 +559,30 @@ #ifdef CONFIG_NET_SCHED to->tc_index = from->tc_index; #endif +#ifdef CONFIG_AVM_PA + memcpy(AVM_PKT_INFO(to), AVM_PKT_INFO(from), sizeof(*AVM_PKT_INFO(to))); +#endif nf_copy(to, from); #if IS_ENABLED(CONFIG_IP_VS) to->ipvs_property = from->ipvs_property; #endif +#ifdef CONFIG_TI_DOCSIS_INPUT_DEV + to->ti_docsis_input_dev = from->ti_docsis_input_dev; + if (to->ti_docsis_input_dev) + { + DBRIDGE_IFINDEX_CHK(to->ti_docsis_input_dev->ifindex, "dev %p, devname %s, ti_docsis_input_dev %p, ti_docsis_input_dev->name %s", to->dev, to->dev ? to->dev->name : NULL, to->ti_docsis_input_dev, to->ti_docsis_input_dev->name); + } +#endif /* CONFIG_TI_DOCSIS_INPUT_DEV */ +#ifdef CONFIG_INTEL_DOCSIS_ICMP_IIF + to->docsis_icmp_iif = from->docsis_icmp_iif; +#endif /* CONFIG_INTEL_DOCSIS_ICMP_IIF */ +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER + to->ti_selective_fwd_dev_info = from->ti_selective_fwd_dev_info; +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ +#ifdef CONFIG_TI_PACKET_PROCESSOR + memcpy((void *)SKB_GET_PP_INFO_P(to), (void *)SKB_GET_PP_INFO_P(from), sizeof(*SKB_GET_PP_INFO_P(from))); +#endif + skb_copy_secmark(to, from); } @@ -784,6 +856,17 @@ iph->tot_len = htons(len + hlen); ip_send_check(iph); +#ifdef CONFIG_TI_PACKET_PROCESSOR + /* If this is not the last frag, clear the PTID Flag */ + if (left > 0 ) + { +#if PUMA7_OR_NEWER_SOC_TYPE + *(Uint32*)(SKB_GET_PP_INFO_P(skb2)->ti_epi_header) &= (~PAL_CPPI4_HOSTDESC_NETINFW0_PTID_FLAG_MASK); +#else + SKB_GET_PP_INFO_P(skb2)->ti_epi_header[4] = 0; +#endif + } +#endif /* CONFIG_TI_PACKET_PROCESSOR */ err = output(net, sk, skb2); if (err) @@ -891,7 +974,11 @@ int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), void *from, int length, int transhdrlen, - unsigned int flags) + unsigned int flags +#ifdef CONFIG_TI_META_DATA +,unsigned int ti_meta_info +#endif +) { struct inet_sock *inet = inet_sk(sk); struct sk_buff *skb; @@ -1025,6 +1112,9 @@ if (!skb) goto error; +#ifdef CONFIG_TI_META_DATA + skb->ti_meta_info = ti_meta_info; +#endif /* CONFIG_TI_META_DATA */ /* * Fill in the control structures */ @@ -1214,7 +1304,11 @@ return __ip_append_data(sk, fl4, &sk->sk_write_queue, &inet->cork.base, sk_page_frag(sk), getfrag, - from, length, transhdrlen, flags); + from, length, transhdrlen, flags +#ifdef CONFIG_TI_META_DATA + ,ipc->ti_meta_info +#endif + ); } ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, @@ -1539,7 +1633,11 @@ err = __ip_append_data(sk, fl4, &queue, &cork, ¤t->task_frag, getfrag, - from, length, transhdrlen, flags); + from, length, transhdrlen, flags +#ifdef CONFIG_TI_META_DATA + ,ipc->ti_meta_info +#endif + ); if (err) { __ip_flush_pending_frames(sk, &queue, &cork); return ERR_PTR(err); @@ -1606,7 +1704,8 @@ RT_SCOPE_UNIVERSE, ip_hdr(skb)->protocol, ip_reply_arg_flowi_flags(arg), daddr, saddr, - tcp_hdr(skb)->source, tcp_hdr(skb)->dest); + tcp_hdr(skb)->source, tcp_hdr(skb)->dest, + arg->uid); security_skb_classify_flow(skb, flowi4_to_flowi(&fl4)); rt = ip_route_output_key(net, &fl4); if (IS_ERR(rt))