netfilter: nfnetlink_log:add support for VLAN information
Subsystems (2)
PATCH 1/1 netfilter: nfnetlink_log:add support for VLAN information
Currently, there is no vlan information (e.g. when used with a vlan aware bridge) passed to userspache, HWHEADER will contain an 08 00 (ip) suffix even for tagged ip packets.
Therefore, add an extra netlink attribute that passes the vlan tag to userspace. Userspace might need to handle PCP/DEI included in this field.
--- include/uapi/linux/netfilter/nfnetlink_log.h | 1 + net/netfilter/nf_log_common.c | 2 ++ net/netfilter/nfnetlink_log.c | 6 ++++++ 3 files changed, 9 insertions(+)
include/uapi/linux/netfilter/nfnetlink_log.h +1 -0
@@ -54,6 +54,7 @@ enum nfulnl_attr_type {NFULA_HWLEN ,/* hardware header length */ NFULA_CT ,/* nf_conntrack_netlink.h */ NFULA_CT_INFO ,/* enum ip_conntrack_info */ +NFULA_VLAN_TAG ,/* __u16 vlan tag */ __NFULA_MAX };
net/netfilter/nf_log_common.c +2 -0
@@ -160,6 +160,8 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf,'0' + loginfo->u.log.level, prefix, in ? in->name :"" , out ? out->name : ""); +if (skb_vlan_tag_present (skb)) +nf_log_buf_add (m,"VLAN=%d " ,skb_vlan_tag_get_id (skb));#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER ) physindev =nf_bridge_get_physindev (skb);if (physindev && in != physindev)
net/netfilter/nfnetlink_log.c +6 -0
@@ -16,6 +16,7 @@#include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/init.h> +#include <linux/if_vlan.h> #include <linux/ip.h> #include <linux/ipv6.h> #include <linux/netdevice.h>
@@ -580,6 +581,11 @@ __build_packet_message(struct nfnl_log_net *log, NFULA_CT, NFULA_CT_INFO) < 0) goto nla_put_failure; +if (skb_vlan_tag_present (skb) && +nla_put_be16 (inst->skb,NFULA_VLAN_TAG , +htons (skb_vlan_tag_get (skb)))) + goto nla_put_failure; +if (data_len) {struct nlattr *nla;int size =nla_attr_size (data_len);
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerQuoted 19 lines · Michael Braun
Currently, there is no vlan information (e.g. when used with a vlan aware bridge) passed to userspache, HWHEADER will contain an 08 00 (ip) suffix even for tagged ip packets.
Therefore, add an extra netlink attribute that passes the vlan tag to userspace. Userspace might need to handle PCP/DEI included in this field.
Signed-off-by Michael Braun <[email protected]>--- include/uapi/linux/netfilter/nfnetlink_log.h | 1 + net/netfilter/nf_log_common.c | 2 ++ net/netfilter/nfnetlink_log.c | 6 ++++++ 3 files changed, 9 insertions(+)include/uapi/linux/netfilter/nfnetlink_log.h +0
-0
include/uapi/linux/netfilter/nfnetlink_log.h enum nfulnl_attr_type { · line 57
Quoted 4 lines
include/uapi/linux/netfilter/nfnetlink_log.h +1
-0@@ -54,6 +54,7 @@ enum nfulnl_attr_type {NFULA_HWLEN ,/* hardware header length */ NFULA_CT ,/* nf_conntrack_netlink.h */ NFULA_CT_INFO ,/* enum ip_conntrack_info */ + NFULA_VLAN_TAG, /* __u16 vlan tag */
Nitpick: Would you rename this to NFULA_VLAN_TCI? Both fields in the vlan header refer to tag, either for protocol or control.
Thanks.
Pablo Neira Ayuso
maintainerQuoted 7 lines · Pablo Neira Ayuso
Quoted 6 lines · Michael Braun
Currently, there is no vlan information (e.g. when used with a vlan aware bridge) passed to userspache, HWHEADER will contain an 08 00 (ip) suffix even for tagged ip packets.
Therefore, add an extra netlink attribute that passes the vlan tag to userspace. Userspace might need to handle PCP/DEI included in this field.
Would you also send patches to update userspace? Thanks.
Florian Westphal
maintainerQuoted 8 lines · Michael Braun
Currently, there is no vlan information (e.g. when used with a vlan aware bridge) passed to userspache, HWHEADER will contain an 08 00 (ip) suffix even for tagged ip packets.
Therefore, add an extra netlink attribute that passes the vlan tag to userspace. Userspace might need to handle PCP/DEI included in this field.
Signed-off-by Michael Braun <[email protected]>
nfqueue has nfqnl_put_bridge() helper which will plcae both tci and proto in a nested attribute, I wonder if we can just re-use that?
(Yes, we need new attributes unfortunately).
Pablo Neira Ayuso
maintainerQuoted 8 lines · Florian Westphal
Quoted 7 lines · Michael Braun
Currently, there is no vlan information (e.g. when used with a vlan aware bridge) passed to userspache, HWHEADER will contain an 08 00 (ip) suffix even for tagged ip packets.
Therefore, add an extra netlink attribute that passes the vlan tag to userspace. Userspace might need to handle PCP/DEI included in this field.
Quoted 6 lines
Quoted 1 line
Signed-off-by Michael Braun <[email protected]>nfqueue has
nfqnl_put_bridge()helper which will plcae both tci and proto in a nested attribute, I wonder if we can just re-use that?(Yes, we need new attributes unfortunately).
Indeed, something similar to nfqnl_put_bridge() would be great to get nfnetlink_log in feature parity with nfnetlink_queue.
Thanks.