--- zzzz-none-000/linux-4.9.279/net/netfilter/nf_conntrack_core.c 2021-08-08 06:38:54.000000000 +0000 +++ puma7-atom-6591-750/linux-4.9.279/net/netfilter/nf_conntrack_core.c 2023-02-08 11:43:43.000000000 +0000 @@ -12,6 +12,12 @@ * published by the Free Software Foundation. */ +/* +* Includes MaxLinear's changes dated: 2021. +* Changed portions - Copyright 2020-2021, MaxLinear, Inc. +* Includes Intel Corporation's changes dated: 2018, 2020. +* Changed portions - Copyright 2018-2020, IntelCorporation. +*/ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include @@ -33,10 +39,10 @@ #include #include #include +#include #include #include #include - #include #include #include @@ -57,7 +63,15 @@ #include #include +#if defined(CONFIG_TI_PACKET_PROCESSOR) && defined(CONFIG_INTEL_KERNEL_PP_DRIVER_LOCAL) +#include +#endif /* CONFIG_TI_PACKET_PROCESSOR and CONFIG_INTEL_KERNEL_PP_DRIVER_LOCAL */ + #define NF_CONNTRACK_VERSION "0.5.0" +/*Some random value to indicate that the delete is due to CT timeout. + *this is required to differentiate conntrack_flush related delete. + */ +#define DEATH_BY_TIMEOUT 11 int (*nfnetlink_parse_nat_setup_hook)(struct nf_conn *ct, enum nf_nat_manip_type manip, @@ -487,6 +501,14 @@ { struct nf_conn_tstamp *tstamp; + /*PP on ATOM specific conntrack ti_hil_pp_event has to go in here */ + /* go ahead and clear the ct record */ +#if defined(CONFIG_TI_PACKET_PROCESSOR) && defined(CONFIG_INTEL_KERNEL_PP_DRIVER_LOCAL) + ti_hil_pp_event (TI_CT_NETFILTER_DELETE, (void *)ct); + if ((ct->ti_pp_status_flag & TI_PP_KILL_CONNTRACK) == 0) + return false; /* HIL Profile took over... */ +#endif /* CONFIG_TI_PACKET_PROCESSOR */ + if (test_and_set_bit(IPS_DYING_BIT, &ct->status)) return false; @@ -496,14 +518,14 @@ tstamp->stop = ktime_get_real_ns(); if (timeout < 0) - tstamp->stop -= jiffies_to_nsecs(-timeout); + tstamp->stop -= jiffies_to_nsecs(-timeout); } if (nf_conntrack_event_report(IPCT_DESTROY, ct, - portid, report) < 0) { + portid, ((report != DEATH_BY_TIMEOUT) ? (report) : 0)) < 0) { /* destroy event was not delivered. nf_ct_put will - * be done by event cache worker on redelivery. - */ + * be done by event cache worker on redelivery. + */ nf_ct_delete_from_lists(ct); nf_conntrack_ecache_delayed_work(nf_ct_net(ct)); return false; @@ -1123,6 +1145,7 @@ goto out; spin_lock_init(&ct->lock); + ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig; ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode.pprev = NULL; ct->tuplehash[IP_CT_DIR_REPLY].tuple = *repl; @@ -1136,9 +1159,20 @@ nf_ct_zone_add(ct, zone); +#if defined(CONFIG_TI_PACKET_PROCESSOR) && defined(CONFIG_INTEL_KERNEL_PP_DRIVER_LOCAL) + INIT_LIST_HEAD(&ct->tuplehash[IP_CT_DIR_ORIGINAL].pp_session_list_head); + INIT_LIST_HEAD(&ct->tuplehash[IP_CT_DIR_REPLY ].pp_session_list_head); + ct->tuplehash[IP_CT_DIR_ORIGINAL].rst_tcp_win = 0; + ct->tuplehash[IP_CT_DIR_REPLY].rst_tcp_win = 0; + ct->ti_pp_status_flag = 0; + + INIT_LIST_HEAD( &ct->scb_link ); +#endif /* CONFIG_TI_PACKET_PROCESSOR */ + /* Because we use RCU lookups, we set ct_general.use to zero before * this is inserted in any list. */ + atomic_set(&ct->ct_general.use, 0); return ct; out: @@ -1280,7 +1314,6 @@ exp->expectfn(ct, exp); nf_ct_expect_put(exp); } - return &ct->tuplehash[IP_CT_DIR_ORIGINAL]; } @@ -1345,6 +1378,18 @@ } skb->nfct = &ct->ct_general; skb->nfctinfo = *ctinfo; + +#if defined(CONFIG_TI_PACKET_PROCESSOR) && defined(CONFIG_INTEL_KERNEL_PP_DRIVER_LOCAL) + { + struct ct_entry_created_t entry_info; + + entry_info.skb = skb; + entry_info.ct = ct; + /* Generate an event indicating that a connection tracking + * entry has been created. */ + ti_hil_pp_event(TI_CT_ENTRY_CREATED, (void *)(&entry_info)); + } +#endif //CONFIG_TI_PACKET_PROCESSOR return ct; } @@ -1419,6 +1464,13 @@ goto out; } +#if defined(CONFIG_TI_PACKET_PROCESSOR) && defined(CONFIG_INTEL_KERNEL_PP_DRIVER_LOCAL) + if (ct->ti_pp_status_flag & TI_PP_BYPASS) + { + TI_HIL_ADD_PP_INFO_FLAGS(skb, TI_HIL_PACKET_FLAG_PP_SESSION_ALG_BYPASS); + } +#endif /* CONFIG_TI_PACKET_PROCESSOR */ + NF_CT_ASSERT(skb->nfct); /* Decide what timeout policy we want to apply to this flow. */ @@ -1522,7 +1574,6 @@ const struct sk_buff *skb) { nf_ct_acct_update(ct, ctinfo, skb->len); - return nf_ct_delete(ct, 0, 0); } EXPORT_SYMBOL_GPL(nf_ct_kill_acct);