@@ -73,6 +73,8 @@ void nf_conntrack_unregister_notifier(struct net *net,
73
73
struct nf_ct_event_notifier * nb );
74
74
75
75
void nf_ct_deliver_cached_events (struct nf_conn * ct );
76
+ int nf_conntrack_eventmask_report (unsigned int eventmask , struct nf_conn * ct ,
77
+ u32 portid , int report );
76
78
77
79
static inline void
78
80
nf_conntrack_event_cache (enum ip_conntrack_events event , struct nf_conn * ct )
@@ -90,70 +92,26 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
90
92
set_bit (event , & e -> cache );
91
93
}
92
94
93
- static inline int
94
- nf_conntrack_eventmask_report (unsigned int eventmask ,
95
- struct nf_conn * ct ,
96
- u32 portid ,
97
- int report )
98
- {
99
- int ret = 0 ;
100
- struct net * net = nf_ct_net (ct );
101
- struct nf_ct_event_notifier * notify ;
102
- struct nf_conntrack_ecache * e ;
103
-
104
- rcu_read_lock ();
105
- notify = rcu_dereference (net -> ct .nf_conntrack_event_cb );
106
- if (notify == NULL )
107
- goto out_unlock ;
108
-
109
- e = nf_ct_ecache_find (ct );
110
- if (e == NULL )
111
- goto out_unlock ;
112
-
113
- if (nf_ct_is_confirmed (ct ) && !nf_ct_is_dying (ct )) {
114
- struct nf_ct_event item = {
115
- .ct = ct ,
116
- .portid = e -> portid ? e -> portid : portid ,
117
- .report = report
118
- };
119
- /* This is a resent of a destroy event? If so, skip missed */
120
- unsigned long missed = e -> portid ? 0 : e -> missed ;
121
-
122
- if (!((eventmask | missed ) & e -> ctmask ))
123
- goto out_unlock ;
124
-
125
- ret = notify -> fcn (eventmask | missed , & item );
126
- if (unlikely (ret < 0 || missed )) {
127
- spin_lock_bh (& ct -> lock );
128
- if (ret < 0 ) {
129
- /* This is a destroy event that has been
130
- * triggered by a process, we store the PORTID
131
- * to include it in the retransmission. */
132
- if (eventmask & (1 << IPCT_DESTROY ) &&
133
- e -> portid == 0 && portid != 0 )
134
- e -> portid = portid ;
135
- else
136
- e -> missed |= eventmask ;
137
- } else
138
- e -> missed &= ~missed ;
139
- spin_unlock_bh (& ct -> lock );
140
- }
141
- }
142
- out_unlock :
143
- rcu_read_unlock ();
144
- return ret ;
145
- }
146
-
147
95
static inline int
148
96
nf_conntrack_event_report (enum ip_conntrack_events event , struct nf_conn * ct ,
149
97
u32 portid , int report )
150
98
{
99
+ const struct net * net = nf_ct_net (ct );
100
+
101
+ if (!rcu_access_pointer (net -> ct .nf_conntrack_event_cb ))
102
+ return 0 ;
103
+
151
104
return nf_conntrack_eventmask_report (1 << event , ct , portid , report );
152
105
}
153
106
154
107
static inline int
155
108
nf_conntrack_event (enum ip_conntrack_events event , struct nf_conn * ct )
156
109
{
110
+ const struct net * net = nf_ct_net (ct );
111
+
112
+ if (!rcu_access_pointer (net -> ct .nf_conntrack_event_cb ))
113
+ return 0 ;
114
+
157
115
return nf_conntrack_eventmask_report (1 << event , ct , 0 , 0 );
158
116
}
159
117
0 commit comments