提交 88c7664f 编写于 作者: A Arnaldo Carvalho de Melo 提交者: David S. Miller

[SK_BUFF]: Introduce icmp_hdr(), remove skb->h.icmph

Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 4bedb452
...@@ -82,6 +82,15 @@ struct icmphdr { ...@@ -82,6 +82,15 @@ struct icmphdr {
} un; } un;
}; };
#ifdef __KERNEL__
#include <linux/skbuff.h>
static inline struct icmphdr *icmp_hdr(const struct sk_buff *skb)
{
return (struct icmphdr *)skb->h.raw;
}
#endif
/* /*
* constants for (set|get)sockopt * constants for (set|get)sockopt
*/ */
......
...@@ -238,7 +238,6 @@ struct sk_buff { ...@@ -238,7 +238,6 @@ struct sk_buff {
union { union {
struct tcphdr *th; struct tcphdr *th;
struct icmphdr *icmph;
struct iphdr *ipiph; struct iphdr *ipiph;
struct ipv6hdr *ipv6h; struct ipv6hdr *ipv6h;
unsigned char *raw; unsigned char *raw;
......
...@@ -207,8 +207,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) ...@@ -207,8 +207,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
(iph->ihl << 2)); (iph->ihl << 2));
struct dccp_sock *dp; struct dccp_sock *dp;
struct inet_sock *inet; struct inet_sock *inet;
const int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
const int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
struct sock *sk; struct sock *sk;
__u64 seq; __u64 seq;
int err; int err;
......
...@@ -198,8 +198,8 @@ static void ah4_err(struct sk_buff *skb, u32 info) ...@@ -198,8 +198,8 @@ static void ah4_err(struct sk_buff *skb, u32 info)
struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+(iph->ihl<<2)); struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+(iph->ihl<<2));
struct xfrm_state *x; struct xfrm_state *x;
if (skb->h.icmph->type != ICMP_DEST_UNREACH || if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
skb->h.icmph->code != ICMP_FRAG_NEEDED) icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
return; return;
x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, ah->spi, IPPROTO_AH, AF_INET); x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, ah->spi, IPPROTO_AH, AF_INET);
......
...@@ -304,8 +304,8 @@ static void esp4_err(struct sk_buff *skb, u32 info) ...@@ -304,8 +304,8 @@ static void esp4_err(struct sk_buff *skb, u32 info)
struct ip_esp_hdr *esph = (struct ip_esp_hdr*)(skb->data+(iph->ihl<<2)); struct ip_esp_hdr *esph = (struct ip_esp_hdr*)(skb->data+(iph->ihl<<2));
struct xfrm_state *x; struct xfrm_state *x;
if (skb->h.icmph->type != ICMP_DEST_UNREACH || if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
skb->h.icmph->code != ICMP_FRAG_NEEDED) icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
return; return;
x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET); x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET);
......
...@@ -355,7 +355,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param, ...@@ -355,7 +355,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
ipc, rt, MSG_DONTWAIT) < 0) ipc, rt, MSG_DONTWAIT) < 0)
ip_flush_pending_frames(icmp_socket->sk); ip_flush_pending_frames(icmp_socket->sk);
else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) { else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) {
struct icmphdr *icmph = skb->h.icmph; struct icmphdr *icmph = icmp_hdr(skb);
__wsum csum = 0; __wsum csum = 0;
struct sk_buff *skb1; struct sk_buff *skb1;
...@@ -613,7 +613,7 @@ static void icmp_unreach(struct sk_buff *skb) ...@@ -613,7 +613,7 @@ static void icmp_unreach(struct sk_buff *skb)
if (!pskb_may_pull(skb, sizeof(struct iphdr))) if (!pskb_may_pull(skb, sizeof(struct iphdr)))
goto out_err; goto out_err;
icmph = skb->h.icmph; icmph = icmp_hdr(skb);
iph = (struct iphdr *)skb->data; iph = (struct iphdr *)skb->data;
if (iph->ihl < 5) /* Mangled header, drop. */ if (iph->ihl < 5) /* Mangled header, drop. */
...@@ -743,7 +743,7 @@ static void icmp_redirect(struct sk_buff *skb) ...@@ -743,7 +743,7 @@ static void icmp_redirect(struct sk_buff *skb)
iph = (struct iphdr *)skb->data; iph = (struct iphdr *)skb->data;
switch (skb->h.icmph->code & 7) { switch (icmp_hdr(skb)->code & 7) {
case ICMP_REDIR_NET: case ICMP_REDIR_NET:
case ICMP_REDIR_NETTOS: case ICMP_REDIR_NETTOS:
/* /*
...@@ -752,7 +752,7 @@ static void icmp_redirect(struct sk_buff *skb) ...@@ -752,7 +752,7 @@ static void icmp_redirect(struct sk_buff *skb)
case ICMP_REDIR_HOST: case ICMP_REDIR_HOST:
case ICMP_REDIR_HOSTTOS: case ICMP_REDIR_HOSTTOS:
ip_rt_redirect(ip_hdr(skb)->saddr, iph->daddr, ip_rt_redirect(ip_hdr(skb)->saddr, iph->daddr,
skb->h.icmph->un.gateway, icmp_hdr(skb)->un.gateway,
iph->saddr, skb->dev); iph->saddr, skb->dev);
break; break;
} }
...@@ -780,7 +780,7 @@ static void icmp_echo(struct sk_buff *skb) ...@@ -780,7 +780,7 @@ static void icmp_echo(struct sk_buff *skb)
if (!sysctl_icmp_echo_ignore_all) { if (!sysctl_icmp_echo_ignore_all) {
struct icmp_bxm icmp_param; struct icmp_bxm icmp_param;
icmp_param.data.icmph = *skb->h.icmph; icmp_param.data.icmph = *icmp_hdr(skb);
icmp_param.data.icmph.type = ICMP_ECHOREPLY; icmp_param.data.icmph.type = ICMP_ECHOREPLY;
icmp_param.skb = skb; icmp_param.skb = skb;
icmp_param.offset = 0; icmp_param.offset = 0;
...@@ -816,7 +816,7 @@ static void icmp_timestamp(struct sk_buff *skb) ...@@ -816,7 +816,7 @@ static void icmp_timestamp(struct sk_buff *skb)
icmp_param.data.times[2] = icmp_param.data.times[1]; icmp_param.data.times[2] = icmp_param.data.times[1];
if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4)) if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
BUG(); BUG();
icmp_param.data.icmph = *skb->h.icmph; icmp_param.data.icmph = *icmp_hdr(skb);
icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY; icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY;
icmp_param.data.icmph.code = 0; icmp_param.data.icmph.code = 0;
icmp_param.skb = skb; icmp_param.skb = skb;
...@@ -943,7 +943,7 @@ int icmp_rcv(struct sk_buff *skb) ...@@ -943,7 +943,7 @@ int icmp_rcv(struct sk_buff *skb)
if (!pskb_pull(skb, sizeof(struct icmphdr))) if (!pskb_pull(skb, sizeof(struct icmphdr)))
goto error; goto error;
icmph = skb->h.icmph; icmph = icmp_hdr(skb);
/* /*
* 18 is the highest 'known' ICMP type. Anything else is a mystery * 18 is the highest 'known' ICMP type. Anything else is a mystery
......
...@@ -320,8 +320,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info) ...@@ -320,8 +320,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
struct iphdr *iph = (struct iphdr*)skb->data; struct iphdr *iph = (struct iphdr*)skb->data;
__be16 *p = (__be16*)(skb->data+(iph->ihl<<2)); __be16 *p = (__be16*)(skb->data+(iph->ihl<<2));
int grehlen = (iph->ihl<<2) + 4; int grehlen = (iph->ihl<<2) + 4;
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
struct ip_tunnel *t; struct ip_tunnel *t;
__be16 flags; __be16 flags;
...@@ -388,8 +388,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info) ...@@ -388,8 +388,8 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
struct iphdr *iph = (struct iphdr*)dp; struct iphdr *iph = (struct iphdr*)dp;
struct iphdr *eiph; struct iphdr *eiph;
__be16 *p = (__be16*)(dp+(iph->ihl<<2)); __be16 *p = (__be16*)(dp+(iph->ihl<<2));
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
int rel_type = 0; int rel_type = 0;
int rel_code = 0; int rel_code = 0;
__be32 rel_info = 0; __be32 rel_info = 0;
...@@ -422,7 +422,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info) ...@@ -422,7 +422,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
default: default:
return; return;
case ICMP_PARAMETERPROB: case ICMP_PARAMETERPROB:
n = ntohl(skb->h.icmph->un.gateway) >> 24; n = ntohl(icmp_hdr(skb)->un.gateway) >> 24;
if (n < (iph->ihl<<2)) if (n < (iph->ihl<<2))
return; return;
...@@ -442,7 +442,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info) ...@@ -442,7 +442,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
return; return;
case ICMP_FRAG_NEEDED: case ICMP_FRAG_NEEDED:
/* And it is the only really necessary thing :-) */ /* And it is the only really necessary thing :-) */
n = ntohs(skb->h.icmph->un.frag.mtu); n = ntohs(icmp_hdr(skb)->un.frag.mtu);
if (n < grehlen+68) if (n < grehlen+68)
return; return;
n -= grehlen; n -= grehlen;
......
...@@ -269,12 +269,12 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, ...@@ -269,12 +269,12 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
serr = SKB_EXT_ERR(skb); serr = SKB_EXT_ERR(skb);
serr->ee.ee_errno = err; serr->ee.ee_errno = err;
serr->ee.ee_origin = SO_EE_ORIGIN_ICMP; serr->ee.ee_origin = SO_EE_ORIGIN_ICMP;
serr->ee.ee_type = skb->h.icmph->type; serr->ee.ee_type = icmp_hdr(skb)->type;
serr->ee.ee_code = skb->h.icmph->code; serr->ee.ee_code = icmp_hdr(skb)->code;
serr->ee.ee_pad = 0; serr->ee.ee_pad = 0;
serr->ee.ee_info = info; serr->ee.ee_info = info;
serr->ee.ee_data = 0; serr->ee.ee_data = 0;
serr->addr_offset = (u8 *)&(((struct iphdr *)(skb->h.icmph + 1))->daddr) - serr->addr_offset = (u8 *)&(((struct iphdr *)(icmp_hdr(skb) + 1))->daddr) -
skb_network_header(skb); skb_network_header(skb);
serr->port = port; serr->port = port;
......
...@@ -174,8 +174,8 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info) ...@@ -174,8 +174,8 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
struct ip_comp_hdr *ipch = (struct ip_comp_hdr *)(skb->data+(iph->ihl<<2)); struct ip_comp_hdr *ipch = (struct ip_comp_hdr *)(skb->data+(iph->ihl<<2));
struct xfrm_state *x; struct xfrm_state *x;
if (skb->h.icmph->type != ICMP_DEST_UNREACH || if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
skb->h.icmph->code != ICMP_FRAG_NEEDED) icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
return; return;
spi = htonl(ntohs(ipch->cpi)); spi = htonl(ntohs(ipch->cpi));
......
...@@ -280,8 +280,8 @@ static int ipip_err(struct sk_buff *skb, u32 info) ...@@ -280,8 +280,8 @@ static int ipip_err(struct sk_buff *skb, u32 info)
ICMP in the real Internet is absolutely infeasible. ICMP in the real Internet is absolutely infeasible.
*/ */
struct iphdr *iph = (struct iphdr*)skb->data; struct iphdr *iph = (struct iphdr*)skb->data;
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
struct ip_tunnel *t; struct ip_tunnel *t;
int err; int err;
...@@ -336,8 +336,8 @@ static int ipip_err(struct sk_buff *skb, u32 info) ...@@ -336,8 +336,8 @@ static int ipip_err(struct sk_buff *skb, u32 info)
struct iphdr *iph = (struct iphdr*)dp; struct iphdr *iph = (struct iphdr*)dp;
int hlen = iph->ihl<<2; int hlen = iph->ihl<<2;
struct iphdr *eiph; struct iphdr *eiph;
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
int rel_type = 0; int rel_type = 0;
int rel_code = 0; int rel_code = 0;
__be32 rel_info = 0; __be32 rel_info = 0;
...@@ -354,7 +354,7 @@ static int ipip_err(struct sk_buff *skb, u32 info) ...@@ -354,7 +354,7 @@ static int ipip_err(struct sk_buff *skb, u32 info)
default: default:
return 0; return 0;
case ICMP_PARAMETERPROB: case ICMP_PARAMETERPROB:
n = ntohl(skb->h.icmph->un.gateway) >> 24; n = ntohl(icmp_hdr(skb)->un.gateway) >> 24;
if (n < hlen) if (n < hlen)
return 0; return 0;
...@@ -373,7 +373,7 @@ static int ipip_err(struct sk_buff *skb, u32 info) ...@@ -373,7 +373,7 @@ static int ipip_err(struct sk_buff *skb, u32 info)
return 0; return 0;
case ICMP_FRAG_NEEDED: case ICMP_FRAG_NEEDED:
/* And it is the only really necessary thing :-) */ /* And it is the only really necessary thing :-) */
n = ntohs(skb->h.icmph->un.frag.mtu); n = ntohs(icmp_hdr(skb)->un.frag.mtu);
if (n < hlen+68) if (n < hlen+68)
return 0; return 0;
n -= hlen; n -= hlen;
......
...@@ -132,7 +132,7 @@ static __inline__ int icmp_filter(struct sock *sk, struct sk_buff *skb) ...@@ -132,7 +132,7 @@ static __inline__ int icmp_filter(struct sock *sk, struct sk_buff *skb)
if (!pskb_may_pull(skb, sizeof(struct icmphdr))) if (!pskb_may_pull(skb, sizeof(struct icmphdr)))
return 1; return 1;
type = skb->h.icmph->type; type = icmp_hdr(skb)->type;
if (type < 32) { if (type < 32) {
__u32 data = raw_sk(sk)->filter.data; __u32 data = raw_sk(sk)->filter.data;
...@@ -184,8 +184,8 @@ int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash) ...@@ -184,8 +184,8 @@ int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash)
void raw_err (struct sock *sk, struct sk_buff *skb, u32 info) void raw_err (struct sock *sk, struct sk_buff *skb, u32 info)
{ {
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
int err = 0; int err = 0;
int harderr = 0; int harderr = 0;
......
...@@ -354,8 +354,8 @@ void tcp_v4_err(struct sk_buff *skb, u32 info) ...@@ -354,8 +354,8 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
struct tcphdr *th = (struct tcphdr *)(skb->data + (iph->ihl << 2)); struct tcphdr *th = (struct tcphdr *)(skb->data + (iph->ihl << 2));
struct tcp_sock *tp; struct tcp_sock *tp;
struct inet_sock *inet; struct inet_sock *inet;
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
struct sock *sk; struct sock *sk;
__u32 seq; __u32 seq;
int err; int err;
......
...@@ -330,8 +330,8 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[]) ...@@ -330,8 +330,8 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[])
struct inet_sock *inet; struct inet_sock *inet;
struct iphdr *iph = (struct iphdr*)skb->data; struct iphdr *iph = (struct iphdr*)skb->data;
struct udphdr *uh = (struct udphdr*)(skb->data+(iph->ihl<<2)); struct udphdr *uh = (struct udphdr*)(skb->data+(iph->ihl<<2));
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
struct sock *sk; struct sock *sk;
int harderr; int harderr;
int err; int err;
......
...@@ -224,8 +224,8 @@ static int ipip6_err(struct sk_buff *skb, u32 info) ...@@ -224,8 +224,8 @@ static int ipip6_err(struct sk_buff *skb, u32 info)
ICMP in the real Internet is absolutely infeasible. ICMP in the real Internet is absolutely infeasible.
*/ */
struct iphdr *iph = (struct iphdr*)skb->data; struct iphdr *iph = (struct iphdr*)skb->data;
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
struct ip_tunnel *t; struct ip_tunnel *t;
int err; int err;
...@@ -280,8 +280,8 @@ static int ipip6_err(struct sk_buff *skb, u32 info) ...@@ -280,8 +280,8 @@ static int ipip6_err(struct sk_buff *skb, u32 info)
struct iphdr *iph = (struct iphdr*)dp; struct iphdr *iph = (struct iphdr*)dp;
int hlen = iph->ihl<<2; int hlen = iph->ihl<<2;
struct ipv6hdr *iph6; struct ipv6hdr *iph6;
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
int rel_type = 0; int rel_type = 0;
int rel_code = 0; int rel_code = 0;
int rel_info = 0; int rel_info = 0;
...@@ -296,14 +296,14 @@ static int ipip6_err(struct sk_buff *skb, u32 info) ...@@ -296,14 +296,14 @@ static int ipip6_err(struct sk_buff *skb, u32 info)
default: default:
return; return;
case ICMP_PARAMETERPROB: case ICMP_PARAMETERPROB:
if (skb->h.icmph->un.gateway < hlen) if (icmp_hdr(skb)->un.gateway < hlen)
return; return;
/* So... This guy found something strange INSIDE encapsulated /* So... This guy found something strange INSIDE encapsulated
packet. Well, he is fool, but what can we do ? packet. Well, he is fool, but what can we do ?
*/ */
rel_type = ICMPV6_PARAMPROB; rel_type = ICMPV6_PARAMPROB;
rel_info = skb->h.icmph->un.gateway - hlen; rel_info = icmp_hdr(skb)->un.gateway - hlen;
break; break;
case ICMP_DEST_UNREACH: case ICMP_DEST_UNREACH:
......
...@@ -507,8 +507,8 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) ...@@ -507,8 +507,8 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
{ {
struct iphdr *iph = (struct iphdr *)skb->data; struct iphdr *iph = (struct iphdr *)skb->data;
struct sctphdr *sh = (struct sctphdr *)(skb->data + (iph->ihl <<2)); struct sctphdr *sh = (struct sctphdr *)(skb->data + (iph->ihl <<2));
int type = skb->h.icmph->type; const int type = icmp_hdr(skb)->type;
int code = skb->h.icmph->code; const int code = icmp_hdr(skb)->code;
struct sock *sk; struct sock *sk;
struct sctp_association *asoc = NULL; struct sctp_association *asoc = NULL;
struct sctp_transport *transport; struct sctp_transport *transport;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册