--- zzzz-none-000/linux-4.4.271/include/net/netfilter/nf_conntrack_ecache.h 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/include/net/netfilter/nf_conntrack_ecache.h 2023-04-19 10:22:30.000000000 +0000 @@ -63,6 +63,12 @@ int report; }; +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS +extern int nf_conntrack_register_notifier(struct net *net, + struct notifier_block *nb); +extern int nf_conntrack_unregister_notifier(struct net *net, + struct notifier_block *nb); +#else struct nf_ct_event_notifier { int (*fcn)(unsigned int events, struct nf_ct_event *item); }; @@ -71,17 +77,20 @@ struct nf_ct_event_notifier *nb); void nf_conntrack_unregister_notifier(struct net *net, struct nf_ct_event_notifier *nb); +#endif void nf_ct_deliver_cached_events(struct nf_conn *ct); static inline void nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) { - struct net *net = nf_ct_net(ct); struct nf_conntrack_ecache *e; +#ifndef CONFIG_NF_CONNTRACK_CHAIN_EVENTS + struct net *net = nf_ct_net(ct); if (!rcu_access_pointer(net->ct.nf_conntrack_event_cb)) return; +#endif e = nf_ct_ecache_find(ct); if (e == NULL) @@ -90,6 +99,39 @@ set_bit(event, &e->cache); } +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS +static inline int +nf_conntrack_eventmask_report(unsigned int eventmask, + struct nf_conn *ct, + u32 portid, + int report) +{ + struct nf_conntrack_ecache *e; + struct net *net = nf_ct_net(ct); + + e = nf_ct_ecache_find(ct); + if (e == NULL) + return 0; + + if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) { + struct nf_ct_event item = { + .ct = ct, + .portid = e->portid ? e->portid : portid, + .report = report + }; + /* This is a resent of a destroy event? If so, skip missed */ + unsigned long missed = e->portid ? 0 : e->missed; + + if (!((eventmask | missed) & e->ctmask)) + return 0; + + atomic_notifier_call_chain(&net->ct.nf_conntrack_chain, + eventmask | missed, &item); + } + + return 0; +} +#else static inline int nf_conntrack_eventmask_report(unsigned int eventmask, struct nf_conn *ct, @@ -143,6 +185,7 @@ rcu_read_unlock(); return ret; } +#endif static inline int nf_conntrack_event_report(enum ip_conntrack_events event, struct nf_conn *ct,