Skip to content

Commit a4b4766

Browse files
chamakenummakynes
authored andcommitted
netfilter: nfnetlink_queue: rename related to nfqueue attaching conntrack info
The idea of this series of patch is to attach conntrack information to nflog like nfqueue has already done. nfqueue conntrack info attaching basis is generic, rename those names to generic one, glue. Signed-off-by: Ken-ichirou MATSUZAWA <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0647e70 commit a4b4766

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

include/linux/netfilter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ struct nf_conn;
377377
enum ip_conntrack_info;
378378
struct nlattr;
379379

380-
struct nfq_ct_hook {
380+
struct nfnl_ct_hook {
381381
struct nf_conn *(*get_ct)(struct sk_buff *skb,
382382
enum ip_conntrack_info *ctinfo);
383383
size_t (*build_size)(const struct nf_conn *ct);
@@ -390,7 +390,7 @@ struct nfq_ct_hook {
390390
void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
391391
enum ip_conntrack_info ctinfo, s32 off);
392392
};
393-
extern struct nfq_ct_hook __rcu *nfq_ct_hook;
393+
extern struct nfnl_ct_hook __rcu *nfnl_ct_hook;
394394

395395
/**
396396
* nf_skb_duplicated - TEE target has sent a packet

net/netfilter/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ EXPORT_SYMBOL(skb_make_writable);
351351
/* This needs to be compiled in any case to avoid dependencies between the
352352
* nfnetlink_queue code and nf_conntrack.
353353
*/
354-
struct nfq_ct_hook __rcu *nfq_ct_hook __read_mostly;
355-
EXPORT_SYMBOL_GPL(nfq_ct_hook);
354+
struct nfnl_ct_hook __rcu *nfnl_ct_hook __read_mostly;
355+
EXPORT_SYMBOL_GPL(nfnl_ct_hook);
356356

357357
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
358358
/* This does not belong here, but locally generated errors need it if connection

net/netfilter/nf_conntrack_netlink.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ ctnetlink_alloc_expect(const struct nlattr *const cda[], struct nf_conn *ct,
21352135

21362136
#ifdef CONFIG_NETFILTER_NETLINK_QUEUE_CT
21372137
static size_t
2138-
ctnetlink_nfqueue_build_size(const struct nf_conn *ct)
2138+
ctnetlink_glue_build_size(const struct nf_conn *ct)
21392139
{
21402140
return 3 * nla_total_size(0) /* CTA_TUPLE_ORIG|REPL|MASTER */
21412141
+ 3 * nla_total_size(0) /* CTA_TUPLE_IP */
@@ -2162,8 +2162,8 @@ ctnetlink_nfqueue_build_size(const struct nf_conn *ct)
21622162
;
21632163
}
21642164

2165-
static struct nf_conn *ctnetlink_nfqueue_get_ct(struct sk_buff *skb,
2166-
enum ip_conntrack_info *ctinfo)
2165+
static struct nf_conn *ctnetlink_glue_get_ct(struct sk_buff *skb,
2166+
enum ip_conntrack_info *ctinfo)
21672167
{
21682168
struct nf_conn *ct;
21692169

@@ -2174,7 +2174,7 @@ static struct nf_conn *ctnetlink_nfqueue_get_ct(struct sk_buff *skb,
21742174
return ct;
21752175
}
21762176

2177-
static int __ctnetlink_nfqueue_build(struct sk_buff *skb, struct nf_conn *ct)
2177+
static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
21782178
{
21792179
const struct nf_conntrack_zone *zone;
21802180
struct nlattr *nest_parms;
@@ -2247,17 +2247,17 @@ static int __ctnetlink_nfqueue_build(struct sk_buff *skb, struct nf_conn *ct)
22472247
}
22482248

22492249
static int
2250-
ctnetlink_nfqueue_build(struct sk_buff *skb, struct nf_conn *ct,
2251-
enum ip_conntrack_info ctinfo,
2252-
u_int16_t ct_attr, u_int16_t ct_info_attr)
2250+
ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct,
2251+
enum ip_conntrack_info ctinfo,
2252+
u_int16_t ct_attr, u_int16_t ct_info_attr)
22532253
{
22542254
struct nlattr *nest_parms;
22552255

22562256
nest_parms = nla_nest_start(skb, ct_attr | NLA_F_NESTED);
22572257
if (!nest_parms)
22582258
goto nla_put_failure;
22592259

2260-
if (__ctnetlink_nfqueue_build(skb, ct) < 0)
2260+
if (__ctnetlink_glue_build(skb, ct) < 0)
22612261
goto nla_put_failure;
22622262

22632263
nla_nest_end(skb, nest_parms);
@@ -2272,7 +2272,7 @@ ctnetlink_nfqueue_build(struct sk_buff *skb, struct nf_conn *ct,
22722272
}
22732273

22742274
static int
2275-
ctnetlink_nfqueue_parse_ct(const struct nlattr *cda[], struct nf_conn *ct)
2275+
ctnetlink_glue_parse_ct(const struct nlattr *cda[], struct nf_conn *ct)
22762276
{
22772277
int err;
22782278

@@ -2312,7 +2312,7 @@ ctnetlink_nfqueue_parse_ct(const struct nlattr *cda[], struct nf_conn *ct)
23122312
}
23132313

23142314
static int
2315-
ctnetlink_nfqueue_parse(const struct nlattr *attr, struct nf_conn *ct)
2315+
ctnetlink_glue_parse(const struct nlattr *attr, struct nf_conn *ct)
23162316
{
23172317
struct nlattr *cda[CTA_MAX+1];
23182318
int ret;
@@ -2322,16 +2322,16 @@ ctnetlink_nfqueue_parse(const struct nlattr *attr, struct nf_conn *ct)
23222322
return ret;
23232323

23242324
spin_lock_bh(&nf_conntrack_expect_lock);
2325-
ret = ctnetlink_nfqueue_parse_ct((const struct nlattr **)cda, ct);
2325+
ret = ctnetlink_glue_parse_ct((const struct nlattr **)cda, ct);
23262326
spin_unlock_bh(&nf_conntrack_expect_lock);
23272327

23282328
return ret;
23292329
}
23302330

2331-
static int ctnetlink_nfqueue_exp_parse(const struct nlattr * const *cda,
2332-
const struct nf_conn *ct,
2333-
struct nf_conntrack_tuple *tuple,
2334-
struct nf_conntrack_tuple *mask)
2331+
static int ctnetlink_glue_exp_parse(const struct nlattr * const *cda,
2332+
const struct nf_conn *ct,
2333+
struct nf_conntrack_tuple *tuple,
2334+
struct nf_conntrack_tuple *mask)
23352335
{
23362336
int err;
23372337

@@ -2345,8 +2345,8 @@ static int ctnetlink_nfqueue_exp_parse(const struct nlattr * const *cda,
23452345
}
23462346

23472347
static int
2348-
ctnetlink_nfqueue_attach_expect(const struct nlattr *attr, struct nf_conn *ct,
2349-
u32 portid, u32 report)
2348+
ctnetlink_glue_attach_expect(const struct nlattr *attr, struct nf_conn *ct,
2349+
u32 portid, u32 report)
23502350
{
23512351
struct nlattr *cda[CTA_EXPECT_MAX+1];
23522352
struct nf_conntrack_tuple tuple, mask;
@@ -2358,8 +2358,8 @@ ctnetlink_nfqueue_attach_expect(const struct nlattr *attr, struct nf_conn *ct,
23582358
if (err < 0)
23592359
return err;
23602360

2361-
err = ctnetlink_nfqueue_exp_parse((const struct nlattr * const *)cda,
2362-
ct, &tuple, &mask);
2361+
err = ctnetlink_glue_exp_parse((const struct nlattr * const *)cda,
2362+
ct, &tuple, &mask);
23632363
if (err < 0)
23642364
return err;
23652365

@@ -2386,22 +2386,22 @@ ctnetlink_nfqueue_attach_expect(const struct nlattr *attr, struct nf_conn *ct,
23862386
return 0;
23872387
}
23882388

2389-
static void ctnetlink_nfqueue_seqadj(struct sk_buff *skb, struct nf_conn *ct,
2390-
enum ip_conntrack_info ctinfo, int diff)
2389+
static void ctnetlink_glue_seqadj(struct sk_buff *skb, struct nf_conn *ct,
2390+
enum ip_conntrack_info ctinfo, int diff)
23912391
{
23922392
if (!(ct->status & IPS_NAT_MASK))
23932393
return;
23942394

23952395
nf_ct_tcp_seqadj_set(skb, ct, ctinfo, diff);
23962396
}
23972397

2398-
static struct nfq_ct_hook ctnetlink_nfqueue_hook = {
2399-
.get_ct = ctnetlink_nfqueue_get_ct,
2400-
.build_size = ctnetlink_nfqueue_build_size,
2401-
.build = ctnetlink_nfqueue_build,
2402-
.parse = ctnetlink_nfqueue_parse,
2403-
.attach_expect = ctnetlink_nfqueue_attach_expect,
2404-
.seq_adjust = ctnetlink_nfqueue_seqadj,
2398+
static struct nfnl_ct_hook ctnetlink_glue_hook = {
2399+
.get_ct = ctnetlink_glue_get_ct,
2400+
.build_size = ctnetlink_glue_build_size,
2401+
.build = ctnetlink_glue_build,
2402+
.parse = ctnetlink_glue_parse,
2403+
.attach_expect = ctnetlink_glue_attach_expect,
2404+
.seq_adjust = ctnetlink_glue_seqadj,
24052405
};
24062406
#endif /* CONFIG_NETFILTER_NETLINK_QUEUE_CT */
24072407

@@ -3389,7 +3389,7 @@ static int __init ctnetlink_init(void)
33893389
}
33903390
#ifdef CONFIG_NETFILTER_NETLINK_QUEUE_CT
33913391
/* setup interaction between nf_queue and nf_conntrack_netlink. */
3392-
RCU_INIT_POINTER(nfq_ct_hook, &ctnetlink_nfqueue_hook);
3392+
RCU_INIT_POINTER(nfnl_ct_hook, &ctnetlink_glue_hook);
33933393
#endif
33943394
return 0;
33953395

@@ -3409,7 +3409,7 @@ static void __exit ctnetlink_exit(void)
34093409
nfnetlink_subsys_unregister(&ctnl_exp_subsys);
34103410
nfnetlink_subsys_unregister(&ctnl_subsys);
34113411
#ifdef CONFIG_NETFILTER_NETLINK_QUEUE_CT
3412-
RCU_INIT_POINTER(nfq_ct_hook, NULL);
3412+
RCU_INIT_POINTER(nfnl_ct_hook, NULL);
34133413
#endif
34143414
}
34153415

net/netfilter/nfnetlink_queue.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
313313
struct net_device *outdev;
314314
struct nf_conn *ct = NULL;
315315
enum ip_conntrack_info uninitialized_var(ctinfo);
316-
struct nfq_ct_hook *nfq_ct;
316+
struct nfnl_ct_hook *nfnl_ct;
317317
bool csum_verify;
318318
char *secdata = NULL;
319319
u32 seclen = 0;
@@ -366,11 +366,11 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
366366
}
367367

368368
if (queue->flags & NFQA_CFG_F_CONNTRACK) {
369-
nfq_ct = rcu_dereference(nfq_ct_hook);
370-
if (nfq_ct != NULL) {
371-
ct = nfq_ct->get_ct(entskb, &ctinfo);
369+
nfnl_ct = rcu_dereference(nfnl_ct_hook);
370+
if (nfnl_ct != NULL) {
371+
ct = nfnl_ct->get_ct(entskb, &ctinfo);
372372
if (ct != NULL)
373-
size += nfq_ct->build_size(ct);
373+
size += nfnl_ct->build_size(ct);
374374
}
375375
}
376376

@@ -516,7 +516,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
516516
if (seclen && nla_put(skb, NFQA_SECCTX, seclen, secdata))
517517
goto nla_put_failure;
518518

519-
if (ct && nfq_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
519+
if (ct && nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
520520
goto nla_put_failure;
521521

522522
if (cap_len > data_len &&
@@ -1009,23 +1009,23 @@ nfqnl_recv_verdict_batch(struct sock *ctnl, struct sk_buff *skb,
10091009
return 0;
10101010
}
10111011

1012-
static struct nf_conn *nfqnl_ct_parse(struct nfq_ct_hook *nfq_ct,
1012+
static struct nf_conn *nfqnl_ct_parse(struct nfnl_ct_hook *nfnl_ct,
10131013
const struct nlmsghdr *nlh,
10141014
const struct nlattr * const nfqa[],
10151015
struct nf_queue_entry *entry,
10161016
enum ip_conntrack_info *ctinfo)
10171017
{
10181018
struct nf_conn *ct;
10191019

1020-
ct = nfq_ct->get_ct(entry->skb, ctinfo);
1020+
ct = nfnl_ct->get_ct(entry->skb, ctinfo);
10211021
if (ct == NULL)
10221022
return NULL;
10231023

1024-
if (nfq_ct->parse(nfqa[NFQA_CT], ct) < 0)
1024+
if (nfnl_ct->parse(nfqa[NFQA_CT], ct) < 0)
10251025
return NULL;
10261026

10271027
if (nfqa[NFQA_EXP])
1028-
nfq_ct->attach_expect(nfqa[NFQA_EXP], ct,
1028+
nfnl_ct->attach_expect(nfqa[NFQA_EXP], ct,
10291029
NETLINK_CB(entry->skb).portid,
10301030
nlmsg_report(nlh));
10311031
return ct;
@@ -1044,7 +1044,7 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
10441044
unsigned int verdict;
10451045
struct nf_queue_entry *entry;
10461046
enum ip_conntrack_info uninitialized_var(ctinfo);
1047-
struct nfq_ct_hook *nfq_ct;
1047+
struct nfnl_ct_hook *nfnl_ct;
10481048
struct nf_conn *ct = NULL;
10491049

10501050
struct net *net = sock_net(ctnl);
@@ -1069,9 +1069,9 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
10691069

10701070
if (nfqa[NFQA_CT]) {
10711071
/* rcu lock already held from nfnl->call_rcu. */
1072-
nfq_ct = rcu_dereference(nfq_ct_hook);
1073-
if (nfq_ct != NULL)
1074-
ct = nfqnl_ct_parse(nfq_ct, nlh, nfqa, entry, &ctinfo);
1072+
nfnl_ct = rcu_dereference(nfnl_ct_hook);
1073+
if (nfnl_ct != NULL)
1074+
ct = nfqnl_ct_parse(nfnl_ct, nlh, nfqa, entry, &ctinfo);
10751075
}
10761076

10771077
if (nfqa[NFQA_PAYLOAD]) {
@@ -1083,7 +1083,7 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
10831083
verdict = NF_DROP;
10841084

10851085
if (ct && diff)
1086-
nfq_ct->seq_adjust(entry->skb, ct, ctinfo, diff);
1086+
nfnl_ct->seq_adjust(entry->skb, ct, ctinfo, diff);
10871087
}
10881088

10891089
if (nfqa[NFQA_MARK])

0 commit comments

Comments
 (0)