Skip to content

Commit da0caad

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter updates for net-next The following patchset contains the first batch of Netfilter updates for your net-next tree. 1) Define pr_fmt() in nf_conntrack, from Weongyo Jeong. 2) Define and register netfilter's afinfo for the bridge family, this comes in preparation for native nfqueue's bridge for nft, from Stephane Bryant. 3) Add new attributes to store layer 2 and VLAN headers to nfqueue, also from Stephane Bryant. 4) Parse new NFQA_VLAN and NFQA_L2HDR nfqueue netlink attributes coming from userspace, from Stephane Bryant. 5) Use net->ipv6.devconf_all->hop_limit instead of hardcoded hop_limit in IPv6 SYNPROXY, from Liping Zhang. 6) Remove unnecessary check for dst == NULL in nf_reject_ipv6, from Haishuang Yan. 7) Deinline ctnetlink event report functions, from Florian Westphal. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 69fb781 + ecdfb48 commit da0caad

File tree

8 files changed

+298
-129
lines changed

8 files changed

+298
-129
lines changed

include/net/netfilter/nf_conntrack_ecache.h

Lines changed: 15 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ void nf_conntrack_unregister_notifier(struct net *net,
7373
struct nf_ct_event_notifier *nb);
7474

7575
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);
7678

7779
static inline void
7880
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)
9092
set_bit(event, &e->cache);
9193
}
9294

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-
14795
static inline int
14896
nf_conntrack_event_report(enum ip_conntrack_events event, struct nf_conn *ct,
14997
u32 portid, int report)
15098
{
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+
151104
return nf_conntrack_eventmask_report(1 << event, ct, portid, report);
152105
}
153106

154107
static inline int
155108
nf_conntrack_event(enum ip_conntrack_events event, struct nf_conn *ct)
156109
{
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+
157115
return nf_conntrack_eventmask_report(1 << event, ct, 0, 0);
158116
}
159117

@@ -172,43 +130,9 @@ int nf_ct_expect_register_notifier(struct net *net,
172130
void nf_ct_expect_unregister_notifier(struct net *net,
173131
struct nf_exp_event_notifier *nb);
174132

175-
static inline void
176-
nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
177-
struct nf_conntrack_expect *exp,
178-
u32 portid,
179-
int report)
180-
{
181-
struct net *net = nf_ct_exp_net(exp);
182-
struct nf_exp_event_notifier *notify;
183-
struct nf_conntrack_ecache *e;
184-
185-
rcu_read_lock();
186-
notify = rcu_dereference(net->ct.nf_expect_event_cb);
187-
if (notify == NULL)
188-
goto out_unlock;
189-
190-
e = nf_ct_ecache_find(exp->master);
191-
if (e == NULL)
192-
goto out_unlock;
193-
194-
if (e->expmask & (1 << event)) {
195-
struct nf_exp_event item = {
196-
.exp = exp,
197-
.portid = portid,
198-
.report = report
199-
};
200-
notify->fcn(1 << event, &item);
201-
}
202-
out_unlock:
203-
rcu_read_unlock();
204-
}
205-
206-
static inline void
207-
nf_ct_expect_event(enum ip_conntrack_expect_events event,
208-
struct nf_conntrack_expect *exp)
209-
{
210-
nf_ct_expect_event_report(event, exp, 0, 0);
211-
}
133+
void nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
134+
struct nf_conntrack_expect *exp,
135+
u32 portid, int report);
212136

213137
int nf_conntrack_ecache_pernet_init(struct net *net);
214138
void nf_conntrack_ecache_pernet_fini(struct net *net);
@@ -245,8 +169,6 @@ static inline int nf_conntrack_event_report(enum ip_conntrack_events event,
245169
u32 portid,
246170
int report) { return 0; }
247171
static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
248-
static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event,
249-
struct nf_conntrack_expect *exp) {}
250172
static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
251173
struct nf_conntrack_expect *exp,
252174
u32 portid,

include/uapi/linux/netfilter/nfnetlink_queue.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ struct nfqnl_msg_packet_timestamp {
3030
__aligned_be64 usec;
3131
};
3232

33+
enum nfqnl_vlan_attr {
34+
NFQA_VLAN_UNSPEC,
35+
NFQA_VLAN_PROTO, /* __be16 skb vlan_proto */
36+
NFQA_VLAN_TCI, /* __be16 skb htons(vlan_tci) */
37+
__NFQA_VLAN_MAX,
38+
};
39+
#define NFQA_VLAN_MAX (__NFQA_VLAN_MAX + 1)
40+
3341
enum nfqnl_attr_type {
3442
NFQA_UNSPEC,
3543
NFQA_PACKET_HDR,
@@ -50,6 +58,8 @@ enum nfqnl_attr_type {
5058
NFQA_UID, /* __u32 sk uid */
5159
NFQA_GID, /* __u32 sk gid */
5260
NFQA_SECCTX, /* security context string */
61+
NFQA_VLAN, /* nested attribute: packet vlan info */
62+
NFQA_L2HDR, /* full L2 header */
5363

5464
__NFQA_MAX
5565
};

net/bridge/netfilter/nf_tables_bridge.c

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,65 @@ static const struct nf_chain_type filter_bridge = {
162162
(1 << NF_BR_POST_ROUTING),
163163
};
164164

165+
static void nf_br_saveroute(const struct sk_buff *skb,
166+
struct nf_queue_entry *entry)
167+
{
168+
}
169+
170+
static int nf_br_reroute(struct net *net, struct sk_buff *skb,
171+
const struct nf_queue_entry *entry)
172+
{
173+
return 0;
174+
}
175+
176+
static __sum16 nf_br_checksum(struct sk_buff *skb, unsigned int hook,
177+
unsigned int dataoff, u_int8_t protocol)
178+
{
179+
return 0;
180+
}
181+
182+
static __sum16 nf_br_checksum_partial(struct sk_buff *skb, unsigned int hook,
183+
unsigned int dataoff, unsigned int len,
184+
u_int8_t protocol)
185+
{
186+
return 0;
187+
}
188+
189+
static int nf_br_route(struct net *net, struct dst_entry **dst,
190+
struct flowi *fl, bool strict __always_unused)
191+
{
192+
return 0;
193+
}
194+
195+
static const struct nf_afinfo nf_br_afinfo = {
196+
.family = AF_BRIDGE,
197+
.checksum = nf_br_checksum,
198+
.checksum_partial = nf_br_checksum_partial,
199+
.route = nf_br_route,
200+
.saveroute = nf_br_saveroute,
201+
.reroute = nf_br_reroute,
202+
.route_key_size = 0,
203+
};
204+
165205
static int __init nf_tables_bridge_init(void)
166206
{
167207
int ret;
168208

209+
nf_register_afinfo(&nf_br_afinfo);
169210
nft_register_chain_type(&filter_bridge);
170211
ret = register_pernet_subsys(&nf_tables_bridge_net_ops);
171-
if (ret < 0)
212+
if (ret < 0) {
172213
nft_unregister_chain_type(&filter_bridge);
173-
214+
nf_unregister_afinfo(&nf_br_afinfo);
215+
}
174216
return ret;
175217
}
176218

177219
static void __exit nf_tables_bridge_exit(void)
178220
{
179221
unregister_pernet_subsys(&nf_tables_bridge_net_ops);
180222
nft_unregister_chain_type(&filter_bridge);
223+
nf_unregister_afinfo(&nf_br_afinfo);
181224
}
182225

183226
module_init(nf_tables_bridge_init);

0 commit comments

Comments
 (0)