netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephane Bryant <stephane.ml.bryant@gmail.com>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org,
	Stephane Bryant <stephane.ml.bryant@gmail.com>
Subject: [PATCH nf-next v4 3/3] netfilter: bridge: nf queue verdict to use NFQA_VLAN and NFQA_L2HDR
Date: Fri, 18 Mar 2016 18:33:36 +0100	[thread overview]
Message-ID: <1458322416-4137-3-git-send-email-stephane.ml.bryant@gmail.com> (raw)
In-Reply-To: <1458322416-4137-1-git-send-email-stephane.ml.bryant@gmail.com>

This makes nf queues use NFQA_VLAN and NFQA_L2HDR in verdict to modify the
original skb

Signed-off-by: Stephane Bryant <stephane.ml.bryant@gmail.com>
---
 net/netfilter/nfnetlink_queue.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index acfc15c..ece25c5 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -1127,6 +1127,31 @@ static int nfqnl_recv_verdict(struct net *net, struct sock *ctnl,
 			ct = nfqnl_ct_parse(nfnl_ct, nlh, nfqa, entry, &ctinfo);
 	}
 
+	if (nfqa[NFQA_VLAN]) {
+		struct nlattr *vlan_tci =
+			nla_find_nested(nfqa[NFQA_VLAN], NFQA_VLAN_TCI);
+		struct nlattr *vlan_proto =
+			nla_find_nested(nfqa[NFQA_VLAN], NFQA_VLAN_PROTO);
+
+		if (vlan_tci)
+			entry->skb->vlan_tci = nla_get_u16(vlan_tci);
+
+		if (vlan_proto)
+			entry->skb->vlan_proto = nla_get_be16(vlan_proto);
+	}
+
+	if (nfqa[NFQA_L2HDR]) {
+		int mac_header_len = entry->skb->network_header -
+			entry->skb->mac_header;
+
+		if (mac_header_len != nla_len(nfqa[NFQA_L2HDR]))
+			verdict = NF_DROP;
+		else if (mac_header_len > 0)
+			memcpy(skb_mac_header(entry->skb),
+			       nla_data(nfqa[NFQA_L2HDR]),
+			       mac_header_len);
+	}
+
 	if (nfqa[NFQA_PAYLOAD]) {
 		u16 payload_len = nla_len(nfqa[NFQA_PAYLOAD]);
 		int diff = payload_len - entry->skb->len;
-- 
2.1.4


      parent reply	other threads:[~2016-03-18 17:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 17:33 [PATCH nf-next v4 1/3] netfilter: bridge: add nf_afinfo to enable queuing to userspace Stephane Bryant
2016-03-18 17:33 ` [PATCH nf-next v4 2/3] netfilter: bridge: pass L2 header and VLAN as netlink attributes in queues " Stephane Bryant
2016-03-18 18:22   ` Florian Westphal
2016-03-18 17:33 ` Stephane Bryant [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458322416-4137-3-git-send-email-stephane.ml.bryant@gmail.com \
    --to=stephane.ml.bryant@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).