Skip to contentSkip to conversation

nfnetlink_log mac address for 6in4 tunnels

PATCH In review Bob Hockney 2 participants 2 messages Dec 5, 2012 – Dec 11, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfnetlink_log mac address for 6in4 tunnels

For tunnelled ipv6in4 packets, the LOG target (xt_LOG.c) adjusts the start of the mac field to start at the ethernet header instead of the ipv4 header for the tunnel. This patch conforms what is passed by the NFLOG target through nfnetlink to what the LOG target does. Code borrowed from xt_LOG.c.

===

net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700 renamed from net/netfilter/nfnetlink_log.c 2012-11-28 17:11:02.285514325 -0700 +11 -3
@@ -382,6 +382,7 @@
        struct nfgenmsg *nfmsg;
        sk_buff_data_t old_tail = inst->skb->tail;
        struct sock *sk;
+       const unsigned char *hwhdrp;
 
        nlh = nlmsg_put(inst->skb, 0, 0,
                        NFNL_SUBSYS_ULOG << 8 | NFULNL_MSG_PACKET,
@@ -483,9 +484,16 @@
        if (indev && skb_mac_header_was_set(skb)) {
                if (nla_put_be16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) ||
                    nla_put_be16(inst->skb, NFULA_HWLEN,
-                                htons(skb->dev->hard_header_len)) ||
-                   nla_put(inst->skb, NFULA_HWHEADER, skb->dev->hard_header_len,
-                           skb_mac_header(skb)))
+                                htons(skb->dev->hard_header_len)))
+                       goto nla_put_failure;
+
+               hwhdrp = skb_mac_header(skb);
+
+               if (skb->dev->type == ARPHRD_SIT)
+                       hwhdrp -= ETH_HLEN;
+
+               if (!(hwhdrp < skb->head) && nla_put(inst->skb, NFULA_HWHEADER,
+                           skb->dev->hard_header_len, hwhdrp))
                        goto nla_put_failure;
        }
 
#1 lore raw

Hi Bob,

Thanks for spotting this.

Quoted 5 lines · Bob Hockney

For tunnelled ipv6in4 packets, the LOG target (xt_LOG.c) adjusts the start of the mac field to start at the ethernet header instead of the ipv4 header for the tunnel. This patch conforms what is passed by the NFLOG target through nfnetlink to what the LOG target does. Code borrowed from xt_LOG.c.

At quick look, this seems good to me, but still I have a couple of comments:

Can send me a log line of xt_LOG to see how it looks in the SIT case?

Would you resend me this patch including the Signed-off-by tag?

Quoted 17 lines

===

net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700 renamed from net/netfilter/nfnetlink_log.c 2012-11-28 17:11:02.285514325 -0700 +1 -2
@@ -382,6 +382,7 @@
        struct nfgenmsg *nfmsg;
        sk_buff_data_t old_tail = inst->skb->tail;
        struct sock *sk;
+       const unsigned char *hwhdrp;
 
        nlh = nlmsg_put(inst->skb, 0, 0,
                        NFNL_SUBSYS_ULOG << 8 | NFULNL_MSG_PACKET,
@@ -483,9 +484,16 @@
        if (indev && skb_mac_header_was_set(skb)) {
                if (nla_put_be16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) ||
                    nla_put_be16(inst->skb, NFULA_HWLEN,
-                                htons(skb->dev->hard_header_len)) ||
-                   nla_put(inst->skb, NFULA_HWHEADER, skb->dev->hard_header_len,

net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700 line 495

Quoted 10 lines
net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700 renamed from net/netfilter/nfnetlink_log.c 2012-11-28 17:11:02.285514325 -0700 +9 -1
-                           skb_mac_header(skb)))
+                                htons(skb->dev->hard_header_len)))
+                       goto nla_put_failure;
+
+               hwhdrp = skb_mac_header(skb);
+
+               if (skb->dev->type == ARPHRD_SIT)
+                       hwhdrp -= ETH_HLEN;
+
+               if (!(hwhdrp < skb->head)  && nla_put(inst->skb, NFULA_HWHEADER,

hwhdrp >= skb->head seems easier to read to me.

Quoted 11 lines
net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700 renamed from net/netfilter/nfnetlink_log.c 2012-11-28 17:11:02.285514325 -0700 +1 -1
+                           skb->dev->hard_header_len, hwhdrp))
                        goto nla_put_failure;
        }
 
 
 
 
--

To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html