lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 26 Apr 2007 09:18:16 -0300
From:	"Arnaldo Carvalho de Melo" <acme@...stprotocols.net>
To:	"David Howells" <dhowells@...hat.com>
Cc:	netdev@...r.kernel.org
Subject: Re: Transforming code to using ICMP packet accessors

On 4/26/07, David Howells <dhowells@...hat.com> wrote:
>
> How do I convert:
>
>         addr = *(__be32 *)(skb->nh.raw + serr->addr_offset);
>
> to use the ICMP accessor macros now that skb->nh is no longer available?  I
> was using this to pluck an address out of the ICMP packet payload, but
>
>         void rxrpc_UDP_error_report(struct sock *sk)
>         {
>                 struct sock_exterr_skb *serr;
>         ...
>                 struct sk_buff *skb;
>                 __be32 addr;
>                 __be16 port;
>         ...
>
>                 skb = skb_dequeue(&sk->sk_error_queue);
>                 if (!skb) {
>                         _leave("UDP socket errqueue empty");
>                         return;
>                 }
>         ...
>
>                 serr = SKB_EXT_ERR(skb);
>                 addr = *(__be32 *)(skb->nh.raw + serr->addr_offset);
>                 port = serr->port;
>
>                 _net("Rx UDP Error from "NIPQUAD_FMT":%hu",
>                      NIPQUAD(addr), ntohs(port));
>         ...
>         }
>
> Should I do this?:
>
>         addr = *(__be32 *)(skb_network_header(skb) + serr->addr_offset);

Yes, as this is the only use in this function.

When there is more than one use, create a pointer from
skb_network_header(skb). That way the skb->head + skb->network_header
math is done just once.

- Arnaldo
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ