--- zzzz-none-000/linux-5.15.111/net/netfilter/nf_conntrack_core.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/net/netfilter/nf_conntrack_core.c 2024-02-07 10:23:30.000000000 +0000 @@ -9,6 +9,12 @@ * (C) 2005-2012 Patrick McHardy */ +/* +* 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 @@ -29,10 +35,10 @@ #include #include #include +#include #include #include #include - #include #include #include @@ -54,6 +60,15 @@ #include "nf_internals.h" +#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 */ + +/*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 + __cacheline_aligned_in_smp spinlock_t nf_conntrack_locks[CONNTRACK_LOCKS]; EXPORT_SYMBOL_GPL(nf_conntrack_locks); @@ -695,6 +710,14 @@ struct nf_conn_tstamp *tstamp; struct net *net; + /*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; @@ -704,11 +727,11 @@ 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. */ @@ -1613,6 +1636,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; @@ -1627,9 +1651,18 @@ 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; +#endif /* CONFIG_TI_PACKET_PROCESSOR */ + /* Because we use RCU lookups, we set ct_general.use to zero before * this is inserted in any list. */ + refcount_set(&ct->ct_general.use, 0); return ct; out: @@ -1758,7 +1791,6 @@ exp->expectfn(ct, exp); nf_ct_expect_put(exp); } - return &ct->tuplehash[IP_CT_DIR_ORIGINAL]; } @@ -1828,6 +1860,18 @@ } } nf_ct_set(skb, ct, 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 0; } @@ -1973,7 +2017,12 @@ ret = NF_ACCEPT; 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 */ ret = nf_conntrack_handle_packet(ct, skb, dataoff, ctinfo, state); if (ret <= 0) { /* Invalid: inverse of the return code tells @@ -2058,7 +2107,6 @@ const struct sk_buff *skb) { nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), skb->len); - return nf_ct_delete(ct, 0, 0); } EXPORT_SYMBOL_GPL(nf_ct_kill_acct);