netfilter: nfnetlink_log:add support for VLAN information
Subsystems (2)
PATCH v3 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 information to userspace similarly to 15824ab29f for nfqueue.
--
v2: mirror nfqueue behaviour
v3: remove dep on CONFIG_BRIDGE_NETFILTER, allow NFPROTO_NETDEV, fix size calc
--- include/uapi/linux/netfilter/nfnetlink_log.h | 11 ++++ net/netfilter/nf_log_common.c | 2 + net/netfilter/nfnetlink_log.c | 57 ++++++++++++++++++++ 3 files changed, 70 insertions(+)
include/uapi/linux/netfilter/nfnetlink_log.h +11 -0
@@ -33,6 +33,15 @@ struct nfulnl_msg_packet_timestamp {__aligned_be64 usec; }; +enum nfulnl_vlan_attr { +NFULA_VLAN_UNSPEC , +NFULA_VLAN_PROTO ,/* __be16 skb vlan_proto */ +NFULA_VLAN_TCI ,/* __be16 skb htons(vlan_tci) */ + __NFULA_VLAN_MAX, +}; + +#define NFULA_VLAN_MAX (__NFULA_VLAN_MAX + 1) +enum nfulnl_attr_type {NFULA_UNSPEC ,NFULA_PACKET_HDR ,
@@ -54,6 +63,8 @@ enum nfulnl_attr_type {NFULA_HWLEN ,/* hardware header length */ NFULA_CT ,/* nf_conntrack_netlink.h */ NFULA_CT_INFO ,/* enum ip_conntrack_info */ +NFULA_VLAN ,/* nested attribute: packet vlan info */ +NFULA_L2HDR ,/* full L2 header */ __NFULA_MAX };
net/netfilter/nf_log_common.c +2 -0
@@ -167,6 +167,8 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf, physoutdev =nf_bridge_get_physoutdev (skb);if (physoutdev && out != physoutdev)nf_log_buf_add (m,"PHYSOUT=%s " , physoutdev->name); +if (skb_vlan_tag_present (skb)) +nf_log_buf_add (m,"VLAN=%d " ,skb_vlan_tag_get_id (skb));#endif }EXPORT_SYMBOL_GPL (nf_log_dump_packet_common);
net/netfilter/nfnetlink_log.c +57 -0
75 lines not on this page · raw message
Signature · 1 line
2.20.1
Quoted 4 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.
Quoted 8 lines
Therefore, add an extra netlink attribute that passes the vlan information to userspace similarly to
15824ab29ffor nfqueue.Signed-off-by Michael Braun <[email protected]>--
v2: mirror nfqueue behaviour
v3: remove dep onCONFIG_BRIDGE_NETFILTER, allowNFPROTO_NETDEV, fix size calc
Looks good, thanks for addressing all the comments.
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 information to userspace similarly to
15824ab29ffor nfqueue.
Applied, with one minor glitch.
[...]
net/netfilter/nf_log_common.c nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf, · line 174
Quoted 13 lines
net/netfilter/nf_log_common.c +2
-0@@ -167,6 +167,8 @@ nf_log_dump_packet_common(struct nf_log_buf *m, u_int8_t pf, physoutdev =nf_bridge_get_physoutdev (skb);if (physoutdev && out != physoutdev)nf_log_buf_add (m,"PHYSOUT=%s " , physoutdev->name); +if (skb_vlan_tag_present (skb)) +nf_log_buf_add (m,"VLAN=%d " ,skb_vlan_tag_get_id (skb));#endif }EXPORT_SYMBOL_GPL (nf_log_dump_packet_common);
I have kept this chunk behind. I think exposing the VPROTO would be useful too. Just send a separated patch for this for review, thanks.