1 // SPDX-License-Identifier: GPL-2.0-only
3 * This is a module which is used for queueing packets and communicating with
4 * userspace via nfnetlink.
6 * (C) 2005 by Harald Welte <laforge@netfilter.org>
7 * (C) 2007 by Patrick McHardy <kaber@trash.net>
9 * Based on the old ipv4-only ip_queue.c:
10 * (C) 2000-2002 James Morris <jmorris@intercode.com.au>
11 * (C) 2003-2005 Netfilter Core Team <coreteam@netfilter.org>
14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16 #include <linux/module.h>
17 #include <linux/skbuff.h>
18 #include <linux/init.h>
19 #include <linux/spinlock.h>
20 #include <linux/slab.h>
21 #include <linux/notifier.h>
22 #include <linux/netdevice.h>
23 #include <linux/netfilter.h>
24 #include <linux/proc_fs.h>
25 #include <linux/netfilter_ipv4.h>
26 #include <linux/netfilter_ipv6.h>
27 #include <linux/netfilter_bridge.h>
28 #include <linux/netfilter/nfnetlink.h>
29 #include <linux/netfilter/nfnetlink_queue.h>
30 #include <linux/netfilter/nf_conntrack_common.h>
31 #include <linux/list.h>
32 #include <linux/cgroup-defs.h>
35 #include <net/tcp_states.h>
36 #include <net/netfilter/nf_queue.h>
37 #include <net/netns/generic.h>
39 #include <linux/atomic.h>
41 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
42 #include "../bridge/br_private.h"
45 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
46 #include <net/netfilter/nf_conntrack.h>
49 #define NFQNL_QMAX_DEFAULT 1024
51 /* We're using struct nlattr which has 16bit nla_len. Note that nla_len
52 * includes the header length. Thus, the maximum packet length that we
53 * support is 65531 bytes. We send truncated packets if the specified length
54 * is larger than that. Userspace can check for presence of NFQA_CAP_LEN
55 * attribute to detect truncation.
57 #define NFQNL_MAX_COPY_RANGE (0xffff - NLA_HDRLEN)
59 struct nfqnl_instance {
60 struct hlist_node hlist; /* global list of queues */
64 unsigned int queue_maxlen;
65 unsigned int copy_range;
66 unsigned int queue_dropped;
67 unsigned int queue_user_dropped;
70 u_int16_t queue_num; /* number of this queue */
72 u_int32_t flags; /* Set using NFQA_CFG_FLAGS */
74 * Following fields are dirtied for each queued packet,
75 * keep them in same cache line if possible.
77 spinlock_t lock ____cacheline_aligned_in_smp;
78 unsigned int queue_total;
79 unsigned int id_sequence; /* 'sequence' of pkt ids */
80 struct list_head queue_list; /* packets in queue */
83 typedef int (*nfqnl_cmpfn)(struct nf_queue_entry *, unsigned long);
85 static unsigned int nfnl_queue_net_id __read_mostly;
87 #define INSTANCE_BUCKETS 16
88 struct nfnl_queue_net {
89 spinlock_t instances_lock;
90 struct hlist_head instance_table[INSTANCE_BUCKETS];
93 static struct nfnl_queue_net *nfnl_queue_pernet(struct net *net)
95 return net_generic(net, nfnl_queue_net_id);
98 static inline u_int8_t instance_hashfn(u_int16_t queue_num)
100 return ((queue_num >> 8) ^ queue_num) % INSTANCE_BUCKETS;
103 static struct nfqnl_instance *
104 instance_lookup(struct nfnl_queue_net *q, u_int16_t queue_num)
106 struct hlist_head *head;
107 struct nfqnl_instance *inst;
109 head = &q->instance_table[instance_hashfn(queue_num)];
110 hlist_for_each_entry_rcu(inst, head, hlist) {
111 if (inst->queue_num == queue_num)
117 static struct nfqnl_instance *
118 instance_create(struct nfnl_queue_net *q, u_int16_t queue_num, u32 portid)
120 struct nfqnl_instance *inst;
124 spin_lock(&q->instances_lock);
125 if (instance_lookup(q, queue_num)) {
130 inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
136 inst->queue_num = queue_num;
137 inst->peer_portid = portid;
138 inst->queue_maxlen = NFQNL_QMAX_DEFAULT;
139 inst->copy_range = NFQNL_MAX_COPY_RANGE;
140 inst->copy_mode = NFQNL_COPY_NONE;
141 spin_lock_init(&inst->lock);
142 INIT_LIST_HEAD(&inst->queue_list);
144 if (!try_module_get(THIS_MODULE)) {
149 h = instance_hashfn(queue_num);
150 hlist_add_head_rcu(&inst->hlist, &q->instance_table[h]);
152 spin_unlock(&q->instances_lock);
159 spin_unlock(&q->instances_lock);
163 static void nfqnl_flush(struct nfqnl_instance *queue, nfqnl_cmpfn cmpfn,
167 instance_destroy_rcu(struct rcu_head *head)
169 struct nfqnl_instance *inst = container_of(head, struct nfqnl_instance,
172 nfqnl_flush(inst, NULL, 0);
174 module_put(THIS_MODULE);
178 __instance_destroy(struct nfqnl_instance *inst)
180 hlist_del_rcu(&inst->hlist);
181 call_rcu(&inst->rcu, instance_destroy_rcu);
185 instance_destroy(struct nfnl_queue_net *q, struct nfqnl_instance *inst)
187 spin_lock(&q->instances_lock);
188 __instance_destroy(inst);
189 spin_unlock(&q->instances_lock);
193 __enqueue_entry(struct nfqnl_instance *queue, struct nf_queue_entry *entry)
195 list_add_tail(&entry->list, &queue->queue_list);
196 queue->queue_total++;
200 __dequeue_entry(struct nfqnl_instance *queue, struct nf_queue_entry *entry)
202 list_del(&entry->list);
203 queue->queue_total--;
206 static struct nf_queue_entry *
207 find_dequeue_entry(struct nfqnl_instance *queue, unsigned int id)
209 struct nf_queue_entry *entry = NULL, *i;
211 spin_lock_bh(&queue->lock);
213 list_for_each_entry(i, &queue->queue_list, list) {
221 __dequeue_entry(queue, entry);
223 spin_unlock_bh(&queue->lock);
228 static void nfqnl_reinject(struct nf_queue_entry *entry, unsigned int verdict)
230 const struct nf_ct_hook *ct_hook;
233 if (verdict == NF_ACCEPT ||
234 verdict == NF_REPEAT ||
235 verdict == NF_STOP) {
237 ct_hook = rcu_dereference(nf_ct_hook);
239 err = ct_hook->update(entry->state.net, entry->skb);
245 nf_reinject(entry, verdict);
249 nfqnl_flush(struct nfqnl_instance *queue, nfqnl_cmpfn cmpfn, unsigned long data)
251 struct nf_queue_entry *entry, *next;
253 spin_lock_bh(&queue->lock);
254 list_for_each_entry_safe(entry, next, &queue->queue_list, list) {
255 if (!cmpfn || cmpfn(entry, data)) {
256 list_del(&entry->list);
257 queue->queue_total--;
258 nfqnl_reinject(entry, NF_DROP);
261 spin_unlock_bh(&queue->lock);
265 nfqnl_put_packet_info(struct sk_buff *nlskb, struct sk_buff *packet,
270 if (packet->ip_summed == CHECKSUM_PARTIAL)
271 flags = NFQA_SKB_CSUMNOTREADY;
272 else if (csum_verify)
273 flags = NFQA_SKB_CSUM_NOTVERIFIED;
275 if (skb_is_gso(packet))
276 flags |= NFQA_SKB_GSO;
278 return flags ? nla_put_be32(nlskb, NFQA_SKB_INFO, htonl(flags)) : 0;
281 static int nfqnl_put_sk_uidgid(struct sk_buff *skb, struct sock *sk)
283 const struct cred *cred;
285 if (!sk_fullsock(sk))
288 read_lock_bh(&sk->sk_callback_lock);
289 if (sk->sk_socket && sk->sk_socket->file) {
290 cred = sk->sk_socket->file->f_cred;
291 if (nla_put_be32(skb, NFQA_UID,
292 htonl(from_kuid_munged(&init_user_ns, cred->fsuid))))
293 goto nla_put_failure;
294 if (nla_put_be32(skb, NFQA_GID,
295 htonl(from_kgid_munged(&init_user_ns, cred->fsgid))))
296 goto nla_put_failure;
298 read_unlock_bh(&sk->sk_callback_lock);
302 read_unlock_bh(&sk->sk_callback_lock);
306 static int nfqnl_put_sk_classid(struct sk_buff *skb, struct sock *sk)
308 #if IS_ENABLED(CONFIG_CGROUP_NET_CLASSID)
309 if (sk && sk_fullsock(sk)) {
310 u32 classid = sock_cgroup_classid(&sk->sk_cgrp_data);
312 if (classid && nla_put_be32(skb, NFQA_CGROUP_CLASSID, htonl(classid)))
319 static u32 nfqnl_get_sk_secctx(struct sk_buff *skb, char **secdata)
322 #if IS_ENABLED(CONFIG_NETWORK_SECMARK)
323 if (!skb || !sk_fullsock(skb->sk))
326 read_lock_bh(&skb->sk->sk_callback_lock);
329 security_secid_to_secctx(skb->secmark, secdata, &seclen);
331 read_unlock_bh(&skb->sk->sk_callback_lock);
336 static u32 nfqnl_get_bridge_size(struct nf_queue_entry *entry)
338 struct sk_buff *entskb = entry->skb;
341 if (entry->state.pf != PF_BRIDGE || !skb_mac_header_was_set(entskb))
344 if (skb_vlan_tag_present(entskb))
345 nlalen += nla_total_size(nla_total_size(sizeof(__be16)) +
346 nla_total_size(sizeof(__be16)));
348 if (entskb->network_header > entskb->mac_header)
349 nlalen += nla_total_size((entskb->network_header -
350 entskb->mac_header));
355 static int nfqnl_put_bridge(struct nf_queue_entry *entry, struct sk_buff *skb)
357 struct sk_buff *entskb = entry->skb;
359 if (entry->state.pf != PF_BRIDGE || !skb_mac_header_was_set(entskb))
362 if (skb_vlan_tag_present(entskb)) {
365 nest = nla_nest_start(skb, NFQA_VLAN);
367 goto nla_put_failure;
369 if (nla_put_be16(skb, NFQA_VLAN_TCI, htons(entskb->vlan_tci)) ||
370 nla_put_be16(skb, NFQA_VLAN_PROTO, entskb->vlan_proto))
371 goto nla_put_failure;
373 nla_nest_end(skb, nest);
376 if (entskb->mac_header < entskb->network_header) {
377 int len = (int)(entskb->network_header - entskb->mac_header);
379 if (nla_put(skb, NFQA_L2HDR, len, skb_mac_header(entskb)))
380 goto nla_put_failure;
389 static struct sk_buff *
390 nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
391 struct nf_queue_entry *entry,
392 __be32 **packet_id_ptr)
395 size_t data_len = 0, cap_len = 0;
396 unsigned int hlen = 0;
399 struct nfqnl_msg_packet_hdr *pmsg;
400 struct nlmsghdr *nlh;
401 struct sk_buff *entskb = entry->skb;
402 struct net_device *indev;
403 struct net_device *outdev;
404 struct nf_conn *ct = NULL;
405 enum ip_conntrack_info ctinfo = 0;
406 const struct nfnl_ct_hook *nfnl_ct;
408 char *secdata = NULL;
412 size = nlmsg_total_size(sizeof(struct nfgenmsg))
413 + nla_total_size(sizeof(struct nfqnl_msg_packet_hdr))
414 + nla_total_size(sizeof(u_int32_t)) /* ifindex */
415 + nla_total_size(sizeof(u_int32_t)) /* ifindex */
416 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
417 + nla_total_size(sizeof(u_int32_t)) /* ifindex */
418 + nla_total_size(sizeof(u_int32_t)) /* ifindex */
420 + nla_total_size(sizeof(u_int32_t)) /* mark */
421 + nla_total_size(sizeof(u_int32_t)) /* priority */
422 + nla_total_size(sizeof(struct nfqnl_msg_packet_hw))
423 + nla_total_size(sizeof(u_int32_t)) /* skbinfo */
424 #if IS_ENABLED(CONFIG_CGROUP_NET_CLASSID)
425 + nla_total_size(sizeof(u_int32_t)) /* classid */
427 + nla_total_size(sizeof(u_int32_t)); /* cap_len */
429 tstamp = skb_tstamp_cond(entskb, false);
431 size += nla_total_size(sizeof(struct nfqnl_msg_packet_timestamp));
433 size += nfqnl_get_bridge_size(entry);
435 if (entry->state.hook <= NF_INET_FORWARD ||
436 (entry->state.hook == NF_INET_POST_ROUTING && entskb->sk == NULL))
437 csum_verify = !skb_csum_unnecessary(entskb);
441 outdev = entry->state.out;
443 switch ((enum nfqnl_config_mode)READ_ONCE(queue->copy_mode)) {
444 case NFQNL_COPY_META:
445 case NFQNL_COPY_NONE:
448 case NFQNL_COPY_PACKET:
449 if (!(queue->flags & NFQA_CFG_F_GSO) &&
450 entskb->ip_summed == CHECKSUM_PARTIAL &&
451 skb_checksum_help(entskb))
454 data_len = READ_ONCE(queue->copy_range);
455 if (data_len > entskb->len)
456 data_len = entskb->len;
458 hlen = skb_zerocopy_headlen(entskb);
459 hlen = min_t(unsigned int, hlen, data_len);
460 size += sizeof(struct nlattr) + hlen;
461 cap_len = entskb->len;
465 nfnl_ct = rcu_dereference(nfnl_ct_hook);
467 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
468 if (queue->flags & NFQA_CFG_F_CONNTRACK) {
469 if (nfnl_ct != NULL) {
470 ct = nf_ct_get(entskb, &ctinfo);
472 size += nfnl_ct->build_size(ct);
477 if (queue->flags & NFQA_CFG_F_UID_GID) {
478 size += (nla_total_size(sizeof(u_int32_t)) /* uid */
479 + nla_total_size(sizeof(u_int32_t))); /* gid */
482 if ((queue->flags & NFQA_CFG_F_SECCTX) && entskb->sk) {
483 seclen = nfqnl_get_sk_secctx(entskb, &secdata);
485 size += nla_total_size(seclen);
488 skb = alloc_skb(size, GFP_ATOMIC);
490 skb_tx_error(entskb);
494 nlh = nfnl_msg_put(skb, 0, 0,
495 nfnl_msg_type(NFNL_SUBSYS_QUEUE, NFQNL_MSG_PACKET),
496 0, entry->state.pf, NFNETLINK_V0,
497 htons(queue->queue_num));
499 skb_tx_error(entskb);
504 nla = __nla_reserve(skb, NFQA_PACKET_HDR, sizeof(*pmsg));
505 pmsg = nla_data(nla);
506 pmsg->hw_protocol = entskb->protocol;
507 pmsg->hook = entry->state.hook;
508 *packet_id_ptr = &pmsg->packet_id;
510 indev = entry->state.in;
512 #if !IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
513 if (nla_put_be32(skb, NFQA_IFINDEX_INDEV, htonl(indev->ifindex)))
514 goto nla_put_failure;
516 if (entry->state.pf == PF_BRIDGE) {
517 /* Case 1: indev is physical input device, we need to
518 * look for bridge group (when called from
519 * netfilter_bridge) */
520 if (nla_put_be32(skb, NFQA_IFINDEX_PHYSINDEV,
521 htonl(indev->ifindex)) ||
522 /* this is the bridge group "brX" */
523 /* rcu_read_lock()ed by __nf_queue */
524 nla_put_be32(skb, NFQA_IFINDEX_INDEV,
525 htonl(br_port_get_rcu(indev)->br->dev->ifindex)))
526 goto nla_put_failure;
530 /* Case 2: indev is bridge group, we need to look for
531 * physical device (when called from ipv4) */
532 if (nla_put_be32(skb, NFQA_IFINDEX_INDEV,
533 htonl(indev->ifindex)))
534 goto nla_put_failure;
536 physinif = nf_bridge_get_physinif(entskb);
538 nla_put_be32(skb, NFQA_IFINDEX_PHYSINDEV,
540 goto nla_put_failure;
546 #if !IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
547 if (nla_put_be32(skb, NFQA_IFINDEX_OUTDEV, htonl(outdev->ifindex)))
548 goto nla_put_failure;
550 if (entry->state.pf == PF_BRIDGE) {
551 /* Case 1: outdev is physical output device, we need to
552 * look for bridge group (when called from
553 * netfilter_bridge) */
554 if (nla_put_be32(skb, NFQA_IFINDEX_PHYSOUTDEV,
555 htonl(outdev->ifindex)) ||
556 /* this is the bridge group "brX" */
557 /* rcu_read_lock()ed by __nf_queue */
558 nla_put_be32(skb, NFQA_IFINDEX_OUTDEV,
559 htonl(br_port_get_rcu(outdev)->br->dev->ifindex)))
560 goto nla_put_failure;
564 /* Case 2: outdev is bridge group, we need to look for
565 * physical output device (when called from ipv4) */
566 if (nla_put_be32(skb, NFQA_IFINDEX_OUTDEV,
567 htonl(outdev->ifindex)))
568 goto nla_put_failure;
570 physoutif = nf_bridge_get_physoutif(entskb);
572 nla_put_be32(skb, NFQA_IFINDEX_PHYSOUTDEV,
574 goto nla_put_failure;
580 nla_put_be32(skb, NFQA_MARK, htonl(entskb->mark)))
581 goto nla_put_failure;
583 if (entskb->priority &&
584 nla_put_be32(skb, NFQA_PRIORITY, htonl(entskb->priority)))
585 goto nla_put_failure;
587 if (indev && entskb->dev &&
588 skb_mac_header_was_set(entskb) &&
589 skb_mac_header_len(entskb) != 0) {
590 struct nfqnl_msg_packet_hw phw;
593 memset(&phw, 0, sizeof(phw));
594 len = dev_parse_header(entskb, phw.hw_addr);
596 phw.hw_addrlen = htons(len);
597 if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))
598 goto nla_put_failure;
602 if (nfqnl_put_bridge(entry, skb) < 0)
603 goto nla_put_failure;
605 if (entry->state.hook <= NF_INET_FORWARD && tstamp) {
606 struct nfqnl_msg_packet_timestamp ts;
607 struct timespec64 kts = ktime_to_timespec64(tstamp);
609 ts.sec = cpu_to_be64(kts.tv_sec);
610 ts.usec = cpu_to_be64(kts.tv_nsec / NSEC_PER_USEC);
612 if (nla_put(skb, NFQA_TIMESTAMP, sizeof(ts), &ts))
613 goto nla_put_failure;
616 if ((queue->flags & NFQA_CFG_F_UID_GID) && entskb->sk &&
617 nfqnl_put_sk_uidgid(skb, entskb->sk) < 0)
618 goto nla_put_failure;
620 if (nfqnl_put_sk_classid(skb, entskb->sk) < 0)
621 goto nla_put_failure;
623 if (seclen && nla_put(skb, NFQA_SECCTX, seclen, secdata))
624 goto nla_put_failure;
626 if (ct && nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
627 goto nla_put_failure;
629 if (cap_len > data_len &&
630 nla_put_be32(skb, NFQA_CAP_LEN, htonl(cap_len)))
631 goto nla_put_failure;
633 if (nfqnl_put_packet_info(skb, entskb, csum_verify))
634 goto nla_put_failure;
639 if (skb_tailroom(skb) < sizeof(*nla) + hlen)
640 goto nla_put_failure;
642 nla = skb_put(skb, sizeof(*nla));
643 nla->nla_type = NFQA_PAYLOAD;
644 nla->nla_len = nla_attr_size(data_len);
646 if (skb_zerocopy(skb, entskb, data_len, hlen))
647 goto nla_put_failure;
650 nlh->nlmsg_len = skb->len;
652 security_release_secctx(secdata, seclen);
656 skb_tx_error(entskb);
658 net_err_ratelimited("nf_queue: error creating packet message\n");
661 security_release_secctx(secdata, seclen);
665 static bool nf_ct_drop_unconfirmed(const struct nf_queue_entry *entry)
667 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
668 static const unsigned long flags = IPS_CONFIRMED | IPS_DYING;
669 const struct nf_conn *ct = (void *)skb_nfct(entry->skb);
671 if (ct && ((ct->status & flags) == IPS_DYING))
678 __nfqnl_enqueue_packet(struct net *net, struct nfqnl_instance *queue,
679 struct nf_queue_entry *entry)
681 struct sk_buff *nskb;
683 __be32 *packet_id_ptr;
686 nskb = nfqnl_build_packet_message(net, queue, entry, &packet_id_ptr);
691 spin_lock_bh(&queue->lock);
693 if (nf_ct_drop_unconfirmed(entry))
694 goto err_out_free_nskb;
696 if (queue->queue_total >= queue->queue_maxlen) {
697 if (queue->flags & NFQA_CFG_F_FAIL_OPEN) {
701 queue->queue_dropped++;
702 net_warn_ratelimited("nf_queue: full at %d entries, dropping packets(s)\n",
705 goto err_out_free_nskb;
707 entry->id = ++queue->id_sequence;
708 *packet_id_ptr = htonl(entry->id);
710 /* nfnetlink_unicast will either free the nskb or add it to a socket */
711 err = nfnetlink_unicast(nskb, net, queue->peer_portid);
713 if (queue->flags & NFQA_CFG_F_FAIL_OPEN) {
717 queue->queue_user_dropped++;
722 __enqueue_entry(queue, entry);
724 spin_unlock_bh(&queue->lock);
730 spin_unlock_bh(&queue->lock);
732 nfqnl_reinject(entry, NF_ACCEPT);
737 static struct nf_queue_entry *
738 nf_queue_entry_dup(struct nf_queue_entry *e)
740 struct nf_queue_entry *entry = kmemdup(e, e->size, GFP_ATOMIC);
745 if (nf_queue_entry_get_refs(entry))
752 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
753 /* When called from bridge netfilter, skb->data must point to MAC header
754 * before calling skb_gso_segment(). Else, original MAC header is lost
755 * and segmented skbs will be sent to wrong destination.
757 static void nf_bridge_adjust_skb_data(struct sk_buff *skb)
759 if (nf_bridge_info_get(skb))
760 __skb_push(skb, skb->network_header - skb->mac_header);
763 static void nf_bridge_adjust_segmented_data(struct sk_buff *skb)
765 if (nf_bridge_info_get(skb))
766 __skb_pull(skb, skb->network_header - skb->mac_header);
769 #define nf_bridge_adjust_skb_data(s) do {} while (0)
770 #define nf_bridge_adjust_segmented_data(s) do {} while (0)
774 __nfqnl_enqueue_packet_gso(struct net *net, struct nfqnl_instance *queue,
775 struct sk_buff *skb, struct nf_queue_entry *entry)
778 struct nf_queue_entry *entry_seg;
780 nf_bridge_adjust_segmented_data(skb);
782 if (skb->next == NULL) { /* last packet, no need to copy entry */
783 struct sk_buff *gso_skb = entry->skb;
785 ret = __nfqnl_enqueue_packet(net, queue, entry);
787 entry->skb = gso_skb;
791 skb_mark_not_on_list(skb);
793 entry_seg = nf_queue_entry_dup(entry);
795 entry_seg->skb = skb;
796 ret = __nfqnl_enqueue_packet(net, queue, entry_seg);
798 nf_queue_entry_free(entry_seg);
804 nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
807 struct nfqnl_instance *queue;
808 struct sk_buff *skb, *segs, *nskb;
810 struct net *net = entry->state.net;
811 struct nfnl_queue_net *q = nfnl_queue_pernet(net);
813 /* rcu_read_lock()ed by nf_hook_thresh */
814 queue = instance_lookup(q, queuenum);
818 if (queue->copy_mode == NFQNL_COPY_NONE)
823 switch (entry->state.pf) {
825 skb->protocol = htons(ETH_P_IP);
828 skb->protocol = htons(ETH_P_IPV6);
832 if ((queue->flags & NFQA_CFG_F_GSO) || !skb_is_gso(skb))
833 return __nfqnl_enqueue_packet(net, queue, entry);
835 nf_bridge_adjust_skb_data(skb);
836 segs = skb_gso_segment(skb, 0);
837 /* Does not use PTR_ERR to limit the number of error codes that can be
838 * returned by nf_queue. For instance, callers rely on -ESRCH to
839 * mean 'ignore this hook'.
841 if (IS_ERR_OR_NULL(segs))
845 skb_list_walk_safe(segs, segs, nskb) {
847 err = __nfqnl_enqueue_packet_gso(net, queue,
856 if (err) /* some segments are already queued */
857 nf_queue_entry_free(entry);
862 nf_bridge_adjust_segmented_data(skb);
867 nfqnl_mangle(void *data, unsigned int data_len, struct nf_queue_entry *e, int diff)
869 struct sk_buff *nskb;
872 unsigned int min_len = skb_transport_offset(e->skb);
874 if (data_len < min_len)
877 if (pskb_trim(e->skb, data_len))
879 } else if (diff > 0) {
880 if (data_len > 0xFFFF)
882 if (diff > skb_tailroom(e->skb)) {
883 nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
890 skb_put(e->skb, diff);
892 if (skb_ensure_writable(e->skb, data_len))
894 skb_copy_to_linear_data(e->skb, data, data_len);
895 e->skb->ip_summed = CHECKSUM_NONE;
900 nfqnl_set_mode(struct nfqnl_instance *queue,
901 unsigned char mode, unsigned int range)
905 spin_lock_bh(&queue->lock);
907 case NFQNL_COPY_NONE:
908 case NFQNL_COPY_META:
909 queue->copy_mode = mode;
910 queue->copy_range = 0;
913 case NFQNL_COPY_PACKET:
914 queue->copy_mode = mode;
915 if (range == 0 || range > NFQNL_MAX_COPY_RANGE)
916 queue->copy_range = NFQNL_MAX_COPY_RANGE;
918 queue->copy_range = range;
925 spin_unlock_bh(&queue->lock);
931 dev_cmp(struct nf_queue_entry *entry, unsigned long ifindex)
933 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
934 int physinif, physoutif;
936 physinif = nf_bridge_get_physinif(entry->skb);
937 physoutif = nf_bridge_get_physoutif(entry->skb);
939 if (physinif == ifindex || physoutif == ifindex)
943 if (entry->state.in->ifindex == ifindex)
945 if (entry->state.out)
946 if (entry->state.out->ifindex == ifindex)
952 /* drop all packets with either indev or outdev == ifindex from all queue
955 nfqnl_dev_drop(struct net *net, int ifindex)
958 struct nfnl_queue_net *q = nfnl_queue_pernet(net);
962 for (i = 0; i < INSTANCE_BUCKETS; i++) {
963 struct nfqnl_instance *inst;
964 struct hlist_head *head = &q->instance_table[i];
966 hlist_for_each_entry_rcu(inst, head, hlist)
967 nfqnl_flush(inst, dev_cmp, ifindex);
974 nfqnl_rcv_dev_event(struct notifier_block *this,
975 unsigned long event, void *ptr)
977 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
979 /* Drop any packets associated with the downed device */
980 if (event == NETDEV_DOWN)
981 nfqnl_dev_drop(dev_net(dev), dev->ifindex);
985 static struct notifier_block nfqnl_dev_notifier = {
986 .notifier_call = nfqnl_rcv_dev_event,
989 static void nfqnl_nf_hook_drop(struct net *net)
991 struct nfnl_queue_net *q = nfnl_queue_pernet(net);
994 /* This function is also called on net namespace error unwind,
995 * when pernet_ops->init() failed and ->exit() functions of the
996 * previous pernet_ops gets called.
998 * This may result in a call to nfqnl_nf_hook_drop() before
999 * struct nfnl_queue_net was allocated.
1004 for (i = 0; i < INSTANCE_BUCKETS; i++) {
1005 struct nfqnl_instance *inst;
1006 struct hlist_head *head = &q->instance_table[i];
1008 hlist_for_each_entry_rcu(inst, head, hlist)
1009 nfqnl_flush(inst, NULL, 0);
1014 nfqnl_rcv_nl_event(struct notifier_block *this,
1015 unsigned long event, void *ptr)
1017 struct netlink_notify *n = ptr;
1018 struct nfnl_queue_net *q = nfnl_queue_pernet(n->net);
1020 if (event == NETLINK_URELEASE && n->protocol == NETLINK_NETFILTER) {
1023 /* destroy all instances for this portid */
1024 spin_lock(&q->instances_lock);
1025 for (i = 0; i < INSTANCE_BUCKETS; i++) {
1026 struct hlist_node *t2;
1027 struct nfqnl_instance *inst;
1028 struct hlist_head *head = &q->instance_table[i];
1030 hlist_for_each_entry_safe(inst, t2, head, hlist) {
1031 if (n->portid == inst->peer_portid)
1032 __instance_destroy(inst);
1035 spin_unlock(&q->instances_lock);
1040 static struct notifier_block nfqnl_rtnl_notifier = {
1041 .notifier_call = nfqnl_rcv_nl_event,
1044 static const struct nla_policy nfqa_vlan_policy[NFQA_VLAN_MAX + 1] = {
1045 [NFQA_VLAN_TCI] = { .type = NLA_U16},
1046 [NFQA_VLAN_PROTO] = { .type = NLA_U16},
1049 static const struct nla_policy nfqa_verdict_policy[NFQA_MAX+1] = {
1050 [NFQA_VERDICT_HDR] = { .len = sizeof(struct nfqnl_msg_verdict_hdr) },
1051 [NFQA_MARK] = { .type = NLA_U32 },
1052 [NFQA_PAYLOAD] = { .type = NLA_UNSPEC },
1053 [NFQA_CT] = { .type = NLA_UNSPEC },
1054 [NFQA_EXP] = { .type = NLA_UNSPEC },
1055 [NFQA_VLAN] = { .type = NLA_NESTED },
1056 [NFQA_PRIORITY] = { .type = NLA_U32 },
1059 static const struct nla_policy nfqa_verdict_batch_policy[NFQA_MAX+1] = {
1060 [NFQA_VERDICT_HDR] = { .len = sizeof(struct nfqnl_msg_verdict_hdr) },
1061 [NFQA_MARK] = { .type = NLA_U32 },
1062 [NFQA_PRIORITY] = { .type = NLA_U32 },
1065 static struct nfqnl_instance *
1066 verdict_instance_lookup(struct nfnl_queue_net *q, u16 queue_num, u32 nlportid)
1068 struct nfqnl_instance *queue;
1070 queue = instance_lookup(q, queue_num);
1072 return ERR_PTR(-ENODEV);
1074 if (queue->peer_portid != nlportid)
1075 return ERR_PTR(-EPERM);
1080 static struct nfqnl_msg_verdict_hdr*
1081 verdicthdr_get(const struct nlattr * const nfqa[])
1083 struct nfqnl_msg_verdict_hdr *vhdr;
1084 unsigned int verdict;
1086 if (!nfqa[NFQA_VERDICT_HDR])
1089 vhdr = nla_data(nfqa[NFQA_VERDICT_HDR]);
1090 verdict = ntohl(vhdr->verdict) & NF_VERDICT_MASK;
1091 if (verdict > NF_MAX_VERDICT || verdict == NF_STOLEN)
1096 static int nfq_id_after(unsigned int id, unsigned int max)
1098 return (int)(id - max) > 0;
1101 static int nfqnl_recv_verdict_batch(struct sk_buff *skb,
1102 const struct nfnl_info *info,
1103 const struct nlattr * const nfqa[])
1105 struct nfnl_queue_net *q = nfnl_queue_pernet(info->net);
1106 u16 queue_num = ntohs(info->nfmsg->res_id);
1107 struct nf_queue_entry *entry, *tmp;
1108 struct nfqnl_msg_verdict_hdr *vhdr;
1109 struct nfqnl_instance *queue;
1110 unsigned int verdict, maxid;
1111 LIST_HEAD(batch_list);
1113 queue = verdict_instance_lookup(q, queue_num,
1114 NETLINK_CB(skb).portid);
1116 return PTR_ERR(queue);
1118 vhdr = verdicthdr_get(nfqa);
1122 verdict = ntohl(vhdr->verdict);
1123 maxid = ntohl(vhdr->id);
1125 spin_lock_bh(&queue->lock);
1127 list_for_each_entry_safe(entry, tmp, &queue->queue_list, list) {
1128 if (nfq_id_after(entry->id, maxid))
1130 __dequeue_entry(queue, entry);
1131 list_add_tail(&entry->list, &batch_list);
1134 spin_unlock_bh(&queue->lock);
1136 if (list_empty(&batch_list))
1139 list_for_each_entry_safe(entry, tmp, &batch_list, list) {
1140 if (nfqa[NFQA_MARK])
1141 entry->skb->mark = ntohl(nla_get_be32(nfqa[NFQA_MARK]));
1143 if (nfqa[NFQA_PRIORITY])
1144 entry->skb->priority = ntohl(nla_get_be32(nfqa[NFQA_PRIORITY]));
1146 nfqnl_reinject(entry, verdict);
1151 static struct nf_conn *nfqnl_ct_parse(const struct nfnl_ct_hook *nfnl_ct,
1152 const struct nlmsghdr *nlh,
1153 const struct nlattr * const nfqa[],
1154 struct nf_queue_entry *entry,
1155 enum ip_conntrack_info *ctinfo)
1157 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
1160 ct = nf_ct_get(entry->skb, ctinfo);
1164 if (nfnl_ct->parse(nfqa[NFQA_CT], ct) < 0)
1168 nfnl_ct->attach_expect(nfqa[NFQA_EXP], ct,
1169 NETLINK_CB(entry->skb).portid,
1177 static int nfqa_parse_bridge(struct nf_queue_entry *entry,
1178 const struct nlattr * const nfqa[])
1180 if (nfqa[NFQA_VLAN]) {
1181 struct nlattr *tb[NFQA_VLAN_MAX + 1];
1184 err = nla_parse_nested_deprecated(tb, NFQA_VLAN_MAX,
1186 nfqa_vlan_policy, NULL);
1190 if (!tb[NFQA_VLAN_TCI] || !tb[NFQA_VLAN_PROTO])
1193 __vlan_hwaccel_put_tag(entry->skb,
1194 nla_get_be16(tb[NFQA_VLAN_PROTO]),
1195 ntohs(nla_get_be16(tb[NFQA_VLAN_TCI])));
1198 if (nfqa[NFQA_L2HDR]) {
1199 int mac_header_len = entry->skb->network_header -
1200 entry->skb->mac_header;
1202 if (mac_header_len != nla_len(nfqa[NFQA_L2HDR]))
1204 else if (mac_header_len > 0)
1205 memcpy(skb_mac_header(entry->skb),
1206 nla_data(nfqa[NFQA_L2HDR]),
1213 static int nfqnl_recv_verdict(struct sk_buff *skb, const struct nfnl_info *info,
1214 const struct nlattr * const nfqa[])
1216 struct nfnl_queue_net *q = nfnl_queue_pernet(info->net);
1217 u_int16_t queue_num = ntohs(info->nfmsg->res_id);
1218 const struct nfnl_ct_hook *nfnl_ct;
1219 struct nfqnl_msg_verdict_hdr *vhdr;
1220 enum ip_conntrack_info ctinfo;
1221 struct nfqnl_instance *queue;
1222 struct nf_queue_entry *entry;
1223 struct nf_conn *ct = NULL;
1224 unsigned int verdict;
1227 queue = verdict_instance_lookup(q, queue_num,
1228 NETLINK_CB(skb).portid);
1230 return PTR_ERR(queue);
1232 vhdr = verdicthdr_get(nfqa);
1236 verdict = ntohl(vhdr->verdict);
1238 entry = find_dequeue_entry(queue, ntohl(vhdr->id));
1242 /* rcu lock already held from nfnl->call_rcu. */
1243 nfnl_ct = rcu_dereference(nfnl_ct_hook);
1245 if (nfqa[NFQA_CT]) {
1246 if (nfnl_ct != NULL)
1247 ct = nfqnl_ct_parse(nfnl_ct, info->nlh, nfqa, entry,
1251 if (entry->state.pf == PF_BRIDGE) {
1252 err = nfqa_parse_bridge(entry, nfqa);
1257 if (nfqa[NFQA_PAYLOAD]) {
1258 u16 payload_len = nla_len(nfqa[NFQA_PAYLOAD]);
1259 int diff = payload_len - entry->skb->len;
1261 if (nfqnl_mangle(nla_data(nfqa[NFQA_PAYLOAD]),
1262 payload_len, entry, diff) < 0)
1266 nfnl_ct->seq_adjust(entry->skb, ct, ctinfo, diff);
1269 if (nfqa[NFQA_MARK])
1270 entry->skb->mark = ntohl(nla_get_be32(nfqa[NFQA_MARK]));
1272 if (nfqa[NFQA_PRIORITY])
1273 entry->skb->priority = ntohl(nla_get_be32(nfqa[NFQA_PRIORITY]));
1275 nfqnl_reinject(entry, verdict);
1279 static int nfqnl_recv_unsupp(struct sk_buff *skb, const struct nfnl_info *info,
1280 const struct nlattr * const cda[])
1285 static const struct nla_policy nfqa_cfg_policy[NFQA_CFG_MAX+1] = {
1286 [NFQA_CFG_CMD] = { .len = sizeof(struct nfqnl_msg_config_cmd) },
1287 [NFQA_CFG_PARAMS] = { .len = sizeof(struct nfqnl_msg_config_params) },
1288 [NFQA_CFG_QUEUE_MAXLEN] = { .type = NLA_U32 },
1289 [NFQA_CFG_MASK] = { .type = NLA_U32 },
1290 [NFQA_CFG_FLAGS] = { .type = NLA_U32 },
1293 static const struct nf_queue_handler nfqh = {
1294 .outfn = nfqnl_enqueue_packet,
1295 .nf_hook_drop = nfqnl_nf_hook_drop,
1298 static int nfqnl_recv_config(struct sk_buff *skb, const struct nfnl_info *info,
1299 const struct nlattr * const nfqa[])
1301 struct nfnl_queue_net *q = nfnl_queue_pernet(info->net);
1302 u_int16_t queue_num = ntohs(info->nfmsg->res_id);
1303 struct nfqnl_msg_config_cmd *cmd = NULL;
1304 struct nfqnl_instance *queue;
1305 __u32 flags = 0, mask = 0;
1308 if (nfqa[NFQA_CFG_CMD]) {
1309 cmd = nla_data(nfqa[NFQA_CFG_CMD]);
1311 /* Obsolete commands without queue context */
1312 switch (cmd->command) {
1313 case NFQNL_CFG_CMD_PF_BIND: return 0;
1314 case NFQNL_CFG_CMD_PF_UNBIND: return 0;
1318 /* Check if we support these flags in first place, dependencies should
1319 * be there too not to break atomicity.
1321 if (nfqa[NFQA_CFG_FLAGS]) {
1322 if (!nfqa[NFQA_CFG_MASK]) {
1323 /* A mask is needed to specify which flags are being
1329 flags = ntohl(nla_get_be32(nfqa[NFQA_CFG_FLAGS]));
1330 mask = ntohl(nla_get_be32(nfqa[NFQA_CFG_MASK]));
1332 if (flags >= NFQA_CFG_F_MAX)
1335 #if !IS_ENABLED(CONFIG_NETWORK_SECMARK)
1336 if (flags & mask & NFQA_CFG_F_SECCTX)
1339 if ((flags & mask & NFQA_CFG_F_CONNTRACK) &&
1340 !rcu_access_pointer(nfnl_ct_hook)) {
1341 #ifdef CONFIG_MODULES
1342 nfnl_unlock(NFNL_SUBSYS_QUEUE);
1343 request_module("ip_conntrack_netlink");
1344 nfnl_lock(NFNL_SUBSYS_QUEUE);
1345 if (rcu_access_pointer(nfnl_ct_hook))
1353 queue = instance_lookup(q, queue_num);
1354 if (queue && queue->peer_portid != NETLINK_CB(skb).portid) {
1356 goto err_out_unlock;
1360 switch (cmd->command) {
1361 case NFQNL_CFG_CMD_BIND:
1364 goto err_out_unlock;
1366 queue = instance_create(q, queue_num,
1367 NETLINK_CB(skb).portid);
1368 if (IS_ERR(queue)) {
1369 ret = PTR_ERR(queue);
1370 goto err_out_unlock;
1373 case NFQNL_CFG_CMD_UNBIND:
1376 goto err_out_unlock;
1378 instance_destroy(q, queue);
1379 goto err_out_unlock;
1380 case NFQNL_CFG_CMD_PF_BIND:
1381 case NFQNL_CFG_CMD_PF_UNBIND:
1385 goto err_out_unlock;
1391 goto err_out_unlock;
1394 if (nfqa[NFQA_CFG_PARAMS]) {
1395 struct nfqnl_msg_config_params *params =
1396 nla_data(nfqa[NFQA_CFG_PARAMS]);
1398 nfqnl_set_mode(queue, params->copy_mode,
1399 ntohl(params->copy_range));
1402 if (nfqa[NFQA_CFG_QUEUE_MAXLEN]) {
1403 __be32 *queue_maxlen = nla_data(nfqa[NFQA_CFG_QUEUE_MAXLEN]);
1405 spin_lock_bh(&queue->lock);
1406 queue->queue_maxlen = ntohl(*queue_maxlen);
1407 spin_unlock_bh(&queue->lock);
1410 if (nfqa[NFQA_CFG_FLAGS]) {
1411 spin_lock_bh(&queue->lock);
1412 queue->flags &= ~mask;
1413 queue->flags |= flags & mask;
1414 spin_unlock_bh(&queue->lock);
1422 static const struct nfnl_callback nfqnl_cb[NFQNL_MSG_MAX] = {
1423 [NFQNL_MSG_PACKET] = {
1424 .call = nfqnl_recv_unsupp,
1425 .type = NFNL_CB_RCU,
1426 .attr_count = NFQA_MAX,
1428 [NFQNL_MSG_VERDICT] = {
1429 .call = nfqnl_recv_verdict,
1430 .type = NFNL_CB_RCU,
1431 .attr_count = NFQA_MAX,
1432 .policy = nfqa_verdict_policy
1434 [NFQNL_MSG_CONFIG] = {
1435 .call = nfqnl_recv_config,
1436 .type = NFNL_CB_MUTEX,
1437 .attr_count = NFQA_CFG_MAX,
1438 .policy = nfqa_cfg_policy
1440 [NFQNL_MSG_VERDICT_BATCH] = {
1441 .call = nfqnl_recv_verdict_batch,
1442 .type = NFNL_CB_RCU,
1443 .attr_count = NFQA_MAX,
1444 .policy = nfqa_verdict_batch_policy
1448 static const struct nfnetlink_subsystem nfqnl_subsys = {
1450 .subsys_id = NFNL_SUBSYS_QUEUE,
1451 .cb_count = NFQNL_MSG_MAX,
1455 #ifdef CONFIG_PROC_FS
1457 struct seq_net_private p;
1458 unsigned int bucket;
1461 static struct hlist_node *get_first(struct seq_file *seq)
1463 struct iter_state *st = seq->private;
1465 struct nfnl_queue_net *q;
1470 net = seq_file_net(seq);
1471 q = nfnl_queue_pernet(net);
1472 for (st->bucket = 0; st->bucket < INSTANCE_BUCKETS; st->bucket++) {
1473 if (!hlist_empty(&q->instance_table[st->bucket]))
1474 return q->instance_table[st->bucket].first;
1479 static struct hlist_node *get_next(struct seq_file *seq, struct hlist_node *h)
1481 struct iter_state *st = seq->private;
1482 struct net *net = seq_file_net(seq);
1486 struct nfnl_queue_net *q;
1488 if (++st->bucket >= INSTANCE_BUCKETS)
1491 q = nfnl_queue_pernet(net);
1492 h = q->instance_table[st->bucket].first;
1497 static struct hlist_node *get_idx(struct seq_file *seq, loff_t pos)
1499 struct hlist_node *head;
1500 head = get_first(seq);
1503 while (pos && (head = get_next(seq, head)))
1505 return pos ? NULL : head;
1508 static void *seq_start(struct seq_file *s, loff_t *pos)
1509 __acquires(nfnl_queue_pernet(seq_file_net(s))->instances_lock)
1511 spin_lock(&nfnl_queue_pernet(seq_file_net(s))->instances_lock);
1512 return get_idx(s, *pos);
1515 static void *seq_next(struct seq_file *s, void *v, loff_t *pos)
1518 return get_next(s, v);
1521 static void seq_stop(struct seq_file *s, void *v)
1522 __releases(nfnl_queue_pernet(seq_file_net(s))->instances_lock)
1524 spin_unlock(&nfnl_queue_pernet(seq_file_net(s))->instances_lock);
1527 static int seq_show(struct seq_file *s, void *v)
1529 const struct nfqnl_instance *inst = v;
1531 seq_printf(s, "%5u %6u %5u %1u %5u %5u %5u %8u %2d\n",
1533 inst->peer_portid, inst->queue_total,
1534 inst->copy_mode, inst->copy_range,
1535 inst->queue_dropped, inst->queue_user_dropped,
1536 inst->id_sequence, 1);
1540 static const struct seq_operations nfqnl_seq_ops = {
1546 #endif /* PROC_FS */
1548 static int __net_init nfnl_queue_net_init(struct net *net)
1551 struct nfnl_queue_net *q = nfnl_queue_pernet(net);
1553 for (i = 0; i < INSTANCE_BUCKETS; i++)
1554 INIT_HLIST_HEAD(&q->instance_table[i]);
1556 spin_lock_init(&q->instances_lock);
1558 #ifdef CONFIG_PROC_FS
1559 if (!proc_create_net("nfnetlink_queue", 0440, net->nf.proc_netfilter,
1560 &nfqnl_seq_ops, sizeof(struct iter_state)))
1566 static void __net_exit nfnl_queue_net_exit(struct net *net)
1568 struct nfnl_queue_net *q = nfnl_queue_pernet(net);
1571 #ifdef CONFIG_PROC_FS
1572 remove_proc_entry("nfnetlink_queue", net->nf.proc_netfilter);
1574 for (i = 0; i < INSTANCE_BUCKETS; i++)
1575 WARN_ON_ONCE(!hlist_empty(&q->instance_table[i]));
1578 static struct pernet_operations nfnl_queue_net_ops = {
1579 .init = nfnl_queue_net_init,
1580 .exit = nfnl_queue_net_exit,
1581 .id = &nfnl_queue_net_id,
1582 .size = sizeof(struct nfnl_queue_net),
1585 static int __init nfnetlink_queue_init(void)
1589 status = register_pernet_subsys(&nfnl_queue_net_ops);
1591 pr_err("failed to register pernet ops\n");
1595 netlink_register_notifier(&nfqnl_rtnl_notifier);
1596 status = nfnetlink_subsys_register(&nfqnl_subsys);
1598 pr_err("failed to create netlink socket\n");
1599 goto cleanup_netlink_notifier;
1602 status = register_netdevice_notifier(&nfqnl_dev_notifier);
1604 pr_err("failed to register netdevice notifier\n");
1605 goto cleanup_netlink_subsys;
1608 nf_register_queue_handler(&nfqh);
1612 cleanup_netlink_subsys:
1613 nfnetlink_subsys_unregister(&nfqnl_subsys);
1614 cleanup_netlink_notifier:
1615 netlink_unregister_notifier(&nfqnl_rtnl_notifier);
1616 unregister_pernet_subsys(&nfnl_queue_net_ops);
1621 static void __exit nfnetlink_queue_fini(void)
1623 nf_unregister_queue_handler();
1624 unregister_netdevice_notifier(&nfqnl_dev_notifier);
1625 nfnetlink_subsys_unregister(&nfqnl_subsys);
1626 netlink_unregister_notifier(&nfqnl_rtnl_notifier);
1627 unregister_pernet_subsys(&nfnl_queue_net_ops);
1629 rcu_barrier(); /* Wait for completion of call_rcu()'s */
1632 MODULE_DESCRIPTION("netfilter packet queue handler");
1633 MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
1634 MODULE_LICENSE("GPL");
1635 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_QUEUE);
1637 module_init(nfnetlink_queue_init);
1638 module_exit(nfnetlink_queue_fini);