* Transforming code to using ICMP packet accessors
@ 2007-04-26 11:23 David Howells
2007-04-26 12:18 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2007-04-26 11:23 UTC (permalink / raw)
To: netdev
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);
David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Transforming code to using ICMP packet accessors
2007-04-26 11:23 Transforming code to using ICMP packet accessors David Howells
@ 2007-04-26 12:18 ` Arnaldo Carvalho de Melo
2007-04-26 12:41 ` David Howells
0 siblings, 1 reply; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2007-04-26 12:18 UTC (permalink / raw)
To: David Howells; +Cc: netdev
On 4/26/07, David Howells <dhowells@redhat.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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Transforming code to using ICMP packet accessors
2007-04-26 12:18 ` Arnaldo Carvalho de Melo
@ 2007-04-26 12:41 ` David Howells
0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2007-04-26 12:41 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: netdev
Arnaldo Carvalho de Melo <acme@ghostprotocols.net> wrote:
> Yes, as this is the only use in this function.
Thanks!
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-26 12:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-26 11:23 Transforming code to using ICMP packet accessors David Howells
2007-04-26 12:18 ` Arnaldo Carvalho de Melo
2007-04-26 12:41 ` David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).