All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfnetlink_log mac address for 6in4 tunnels
@ 2012-12-13 17:37 Bob Hockney
  2012-12-16 22:47 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 5+ messages in thread
From: Bob Hockney @ 2012-12-13 17:37 UTC (permalink / raw)
  To: netfilter-devel


For tunneled 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.

Here are before and after log lines.  The kernel: lines are with the LOG
target, the ulogd lines are with NFLOG, ulogd and its SYSLOG  plugin:

Log lines for the same packet, before patch:

Dec  3 09:07:22 gateway kernel: [   69.268396] INVALID IN=he-ipv6 OUT=eth1
MAC=00:50:8d:bf:02:01:68:ef:bd:f0:7d:d9:08:00:45:00:00:5c:00:00:40:00:fa:29:
64:c2:42:dc:12:2a:18:31:ae:7f TUNNEL=66.220.18.42->w.x.y.z SRC= ...
Dec  3 09:07:22 gateway ulogd[1628]: INVALID  IN=he-ipv6 OUT=eth1
MAC=45:00:00:5c:00:00:40:00:fa:29:64:c2:42:dc:12:2a:18:31:ae:7f:68:00:00:00:
00:20:06:35:2a:03:28:80:00:10 SRC= ...

Log lines after patch:

Dec  3 09:08:44 gateway kernel: [   32.998288] INVALID IN=he-ipv6 OUT=eth1
MAC=00:50:8d:bf:02:01:68:ef:bd:f0:7d:d9:08:00:45:00:00:5c:00:00:40:00:fa:29:
64:c2:42:dc:12:2a:18:31:ae:7f TUNNEL=66.220.18.42->w.x.y.z SRC= ...
Dec  3 09:08:45 gateway ulogd[1488]: INVALID  IN=he-ipv6 OUT=eth1
MAC=00:50:8d:bf:02:01:68:ef:bd:f0:7d:d9:08:00:45:00:00:5c:00:00:40:00:fa:29:
64:c2:42:dc:12:2a:18:31:ae:7f SRC= ...

Signed-off-by: Bob Hockney <bhockney@ix.netcom.com>

===

--- a/net/netfilter/nfnetlink_log.c        2012-11-28 17:11:02.285514325
-0700
+++ b/net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700
@@ -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;
        }



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfnetlink_log mac address for 6in4 tunnels
  2012-12-13 17:37 [PATCH] nfnetlink_log mac address for 6in4 tunnels Bob Hockney
@ 2012-12-16 22:47 ` Pablo Neira Ayuso
  2012-12-17  2:29   ` Bob Hockney
  0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2012-12-16 22:47 UTC (permalink / raw)
  To: Bob Hockney; +Cc: netfilter-devel

On Thu, Dec 13, 2012 at 10:37:02AM -0700, Bob Hockney wrote:
> 
> For tunneled 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.
> 
> Here are before and after log lines.  The kernel: lines are with the LOG
> target, the ulogd lines are with NFLOG, ulogd and its SYSLOG  plugin:
> 
> Log lines for the same packet, before patch:
> 
> Dec  3 09:07:22 gateway kernel: [   69.268396] INVALID IN=he-ipv6 OUT=eth1
> MAC=00:50:8d:bf:02:01:68:ef:bd:f0:7d:d9:08:00:45:00:00:5c:00:00:40:00:fa:29:
> 64:c2:42:dc:12:2a:18:31:ae:7f TUNNEL=66.220.18.42->w.x.y.z SRC= ...
> Dec  3 09:07:22 gateway ulogd[1628]: INVALID  IN=he-ipv6 OUT=eth1
> MAC=45:00:00:5c:00:00:40:00:fa:29:64:c2:42:dc:12:2a:18:31:ae:7f:68:00:00:00:
> 00:20:06:35:2a:03:28:80:00:10 SRC= ...
> 
> Log lines after patch:
> 
> Dec  3 09:08:44 gateway kernel: [   32.998288] INVALID IN=he-ipv6 OUT=eth1
> MAC=00:50:8d:bf:02:01:68:ef:bd:f0:7d:d9:08:00:45:00:00:5c:00:00:40:00:fa:29:
> 64:c2:42:dc:12:2a:18:31:ae:7f TUNNEL=66.220.18.42->w.x.y.z SRC= ...
> Dec  3 09:08:45 gateway ulogd[1488]: INVALID  IN=he-ipv6 OUT=eth1
> MAC=00:50:8d:bf:02:01:68:ef:bd:f0:7d:d9:08:00:45:00:00:5c:00:00:40:00:fa:29:
> 64:c2:42:dc:12:2a:18:31:ae:7f SRC= ...

Applied.

Please, next time you have to base your patch on some recent linux
kernel tree. You can get it via git or just some snapshot via
kernel.org, I'm telling this because I had to rebase this patch upon
current.

Thanks Bob.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] nfnetlink_log mac address for 6in4 tunnels
  2012-12-16 22:47 ` Pablo Neira Ayuso
@ 2012-12-17  2:29   ` Bob Hockney
  0 siblings, 0 replies; 5+ messages in thread
From: Bob Hockney @ 2012-12-17  2:29 UTC (permalink / raw)
  To: 'Pablo Neira Ayuso'; +Cc: netfilter-devel


> Applied.
> 
> Please, next time you have to base your patch on some recent linux kernel
tree.
> You can get it via git or just some snapshot via kernel.org, I'm telling
this
> because I had to rebase this patch upon current.

OK, I will.  Thanks Pablo.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] nfnetlink_log mac address for 6in4 tunnels
  2012-12-05 18:05 Bob Hockney
@ 2012-12-11 11:33 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2012-12-11 11:33 UTC (permalink / raw)
  To: Bob Hockney; +Cc: netfilter-devel

Hi Bob,

Thanks for spotting this.

On Wed, Dec 05, 2012 at 11:05:21AM -0700, Bob Hockney wrote:
> 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?

> ===
> --- a/net/netfilter/nfnetlink_log.c        2012-11-28 17:11:02.285514325 -0700
> +++ b/net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700
> @@ -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,

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

> +                           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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] nfnetlink_log mac address for 6in4 tunnels
@ 2012-12-05 18:05 Bob Hockney
  2012-12-11 11:33 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 5+ messages in thread
From: Bob Hockney @ 2012-12-05 18:05 UTC (permalink / raw)
  To: netfilter-devel

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.

===
--- a/net/netfilter/nfnetlink_log.c        2012-11-28 17:11:02.285514325 -0700
+++ b/net/netfilter/nfnetlink_log.c 2012-11-28 17:10:38.551830948 -0700
@@ -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;
        }





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-12-17  2:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-13 17:37 [PATCH] nfnetlink_log mac address for 6in4 tunnels Bob Hockney
2012-12-16 22:47 ` Pablo Neira Ayuso
2012-12-17  2:29   ` Bob Hockney
  -- strict thread matches above, loose matches on Subject: below --
2012-12-05 18:05 Bob Hockney
2012-12-11 11:33 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.