Skip to content

Commit ecdfb48

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: conntrack: move expectation event helper to ecache.c
Not performance critical, it is only invoked when an expectation is added/destroyed. While at it, kill unused nf_ct_expect_event() wrapper. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 3c435e2 commit ecdfb48

File tree

2 files changed

+33
-39
lines changed

2 files changed

+33
-39
lines changed

include/net/netfilter/nf_conntrack_ecache.h

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -130,43 +130,9 @@ int nf_ct_expect_register_notifier(struct net *net,
130130
void nf_ct_expect_unregister_notifier(struct net *net,
131131
struct nf_exp_event_notifier *nb);
132132

133-
static inline void
134-
nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
135-
struct nf_conntrack_expect *exp,
136-
u32 portid,
137-
int report)
138-
{
139-
struct net *net = nf_ct_exp_net(exp);
140-
struct nf_exp_event_notifier *notify;
141-
struct nf_conntrack_ecache *e;
142-
143-
rcu_read_lock();
144-
notify = rcu_dereference(net->ct.nf_expect_event_cb);
145-
if (notify == NULL)
146-
goto out_unlock;
147-
148-
e = nf_ct_ecache_find(exp->master);
149-
if (e == NULL)
150-
goto out_unlock;
151-
152-
if (e->expmask & (1 << event)) {
153-
struct nf_exp_event item = {
154-
.exp = exp,
155-
.portid = portid,
156-
.report = report
157-
};
158-
notify->fcn(1 << event, &item);
159-
}
160-
out_unlock:
161-
rcu_read_unlock();
162-
}
163-
164-
static inline void
165-
nf_ct_expect_event(enum ip_conntrack_expect_events event,
166-
struct nf_conntrack_expect *exp)
167-
{
168-
nf_ct_expect_event_report(event, exp, 0, 0);
169-
}
133+
void nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
134+
struct nf_conntrack_expect *exp,
135+
u32 portid, int report);
170136

171137
int nf_conntrack_ecache_pernet_init(struct net *net);
172138
void nf_conntrack_ecache_pernet_fini(struct net *net);
@@ -203,8 +169,6 @@ static inline int nf_conntrack_event_report(enum ip_conntrack_events event,
203169
u32 portid,
204170
int report) { return 0; }
205171
static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
206-
static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event,
207-
struct nf_conntrack_expect *exp) {}
208172
static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
209173
struct nf_conntrack_expect *exp,
210174
u32 portid,

net/netfilter/nf_conntrack_ecache.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,36 @@ void nf_ct_deliver_cached_events(struct nf_conn *ct)
221221
}
222222
EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events);
223223

224+
void nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
225+
struct nf_conntrack_expect *exp,
226+
u32 portid, int report)
227+
228+
{
229+
struct net *net = nf_ct_exp_net(exp);
230+
struct nf_exp_event_notifier *notify;
231+
struct nf_conntrack_ecache *e;
232+
233+
rcu_read_lock();
234+
notify = rcu_dereference(net->ct.nf_expect_event_cb);
235+
if (!notify)
236+
goto out_unlock;
237+
238+
e = nf_ct_ecache_find(exp->master);
239+
if (!e)
240+
goto out_unlock;
241+
242+
if (e->expmask & (1 << event)) {
243+
struct nf_exp_event item = {
244+
.exp = exp,
245+
.portid = portid,
246+
.report = report
247+
};
248+
notify->fcn(1 << event, &item);
249+
}
250+
out_unlock:
251+
rcu_read_unlock();
252+
}
253+
224254
int nf_conntrack_register_notifier(struct net *net,
225255
struct nf_ct_event_notifier *new)
226256
{

0 commit comments

Comments
 (0)