[SK_BUFF]: Introduce icmp_hdr(), remove skb->h.icmph
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4bedb45203
commit
88c7664f13
@ -82,6 +82,15 @@ struct icmphdr {
|
||||
} 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
|
||||
*/
|
||||
|
@ -238,7 +238,6 @@ struct sk_buff {
|
||||
|
||||
union {
|
||||
struct tcphdr *th;
|
||||
struct icmphdr *icmph;
|
||||
struct iphdr *ipiph;
|
||||
struct ipv6hdr *ipv6h;
|
||||
unsigned char *raw;
|
||||
|
@ -207,8 +207,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
|
||||
(iph->ihl << 2));
|
||||
struct dccp_sock *dp;
|
||||
struct inet_sock *inet;
|
||||
const int type = skb->h.icmph->type;
|
||||
const int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct sock *sk;
|
||||
__u64 seq;
|
||||
int err;
|
||||
|
@ -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 xfrm_state *x;
|
||||
|
||||
if (skb->h.icmph->type != ICMP_DEST_UNREACH ||
|
||||
skb->h.icmph->code != ICMP_FRAG_NEEDED)
|
||||
if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
|
||||
icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
|
||||
return;
|
||||
|
||||
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)
|
||||
struct ip_esp_hdr *esph = (struct ip_esp_hdr*)(skb->data+(iph->ihl<<2));
|
||||
struct xfrm_state *x;
|
||||
|
||||
if (skb->h.icmph->type != ICMP_DEST_UNREACH ||
|
||||
skb->h.icmph->code != ICMP_FRAG_NEEDED)
|
||||
if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
|
||||
icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
|
||||
return;
|
||||
|
||||
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,
|
||||
ipc, rt, MSG_DONTWAIT) < 0)
|
||||
ip_flush_pending_frames(icmp_socket->sk);
|
||||
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;
|
||||
struct sk_buff *skb1;
|
||||
|
||||
@ -613,7 +613,7 @@ static void icmp_unreach(struct sk_buff *skb)
|
||||
if (!pskb_may_pull(skb, sizeof(struct iphdr)))
|
||||
goto out_err;
|
||||
|
||||
icmph = skb->h.icmph;
|
||||
icmph = icmp_hdr(skb);
|
||||
iph = (struct iphdr *)skb->data;
|
||||
|
||||
if (iph->ihl < 5) /* Mangled header, drop. */
|
||||
@ -743,7 +743,7 @@ static void icmp_redirect(struct sk_buff *skb)
|
||||
|
||||
iph = (struct iphdr *)skb->data;
|
||||
|
||||
switch (skb->h.icmph->code & 7) {
|
||||
switch (icmp_hdr(skb)->code & 7) {
|
||||
case ICMP_REDIR_NET:
|
||||
case ICMP_REDIR_NETTOS:
|
||||
/*
|
||||
@ -752,7 +752,7 @@ static void icmp_redirect(struct sk_buff *skb)
|
||||
case ICMP_REDIR_HOST:
|
||||
case ICMP_REDIR_HOSTTOS:
|
||||
ip_rt_redirect(ip_hdr(skb)->saddr, iph->daddr,
|
||||
skb->h.icmph->un.gateway,
|
||||
icmp_hdr(skb)->un.gateway,
|
||||
iph->saddr, skb->dev);
|
||||
break;
|
||||
}
|
||||
@ -780,7 +780,7 @@ static void icmp_echo(struct sk_buff *skb)
|
||||
if (!sysctl_icmp_echo_ignore_all) {
|
||||
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.skb = skb;
|
||||
icmp_param.offset = 0;
|
||||
@ -816,7 +816,7 @@ static void icmp_timestamp(struct sk_buff *skb)
|
||||
icmp_param.data.times[2] = icmp_param.data.times[1];
|
||||
if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
|
||||
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.code = 0;
|
||||
icmp_param.skb = skb;
|
||||
@ -943,7 +943,7 @@ int icmp_rcv(struct sk_buff *skb)
|
||||
if (!pskb_pull(skb, sizeof(struct icmphdr)))
|
||||
goto error;
|
||||
|
||||
icmph = skb->h.icmph;
|
||||
icmph = icmp_hdr(skb);
|
||||
|
||||
/*
|
||||
* 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)
|
||||
struct iphdr *iph = (struct iphdr*)skb->data;
|
||||
__be16 *p = (__be16*)(skb->data+(iph->ihl<<2));
|
||||
int grehlen = (iph->ihl<<2) + 4;
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct ip_tunnel *t;
|
||||
__be16 flags;
|
||||
|
||||
@ -388,8 +388,8 @@ out:
|
||||
struct iphdr *iph = (struct iphdr*)dp;
|
||||
struct iphdr *eiph;
|
||||
__be16 *p = (__be16*)(dp+(iph->ihl<<2));
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
int rel_type = 0;
|
||||
int rel_code = 0;
|
||||
__be32 rel_info = 0;
|
||||
@ -422,7 +422,7 @@ out:
|
||||
default:
|
||||
return;
|
||||
case ICMP_PARAMETERPROB:
|
||||
n = ntohl(skb->h.icmph->un.gateway) >> 24;
|
||||
n = ntohl(icmp_hdr(skb)->un.gateway) >> 24;
|
||||
if (n < (iph->ihl<<2))
|
||||
return;
|
||||
|
||||
@ -442,7 +442,7 @@ out:
|
||||
return;
|
||||
case ICMP_FRAG_NEEDED:
|
||||
/* 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)
|
||||
return;
|
||||
n -= grehlen;
|
||||
|
@ -269,12 +269,12 @@ void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
|
||||
serr = SKB_EXT_ERR(skb);
|
||||
serr->ee.ee_errno = err;
|
||||
serr->ee.ee_origin = SO_EE_ORIGIN_ICMP;
|
||||
serr->ee.ee_type = skb->h.icmph->type;
|
||||
serr->ee.ee_code = skb->h.icmph->code;
|
||||
serr->ee.ee_type = icmp_hdr(skb)->type;
|
||||
serr->ee.ee_code = icmp_hdr(skb)->code;
|
||||
serr->ee.ee_pad = 0;
|
||||
serr->ee.ee_info = info;
|
||||
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);
|
||||
serr->port = port;
|
||||
|
||||
|
@ -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 xfrm_state *x;
|
||||
|
||||
if (skb->h.icmph->type != ICMP_DEST_UNREACH ||
|
||||
skb->h.icmph->code != ICMP_FRAG_NEEDED)
|
||||
if (icmp_hdr(skb)->type != ICMP_DEST_UNREACH ||
|
||||
icmp_hdr(skb)->code != ICMP_FRAG_NEEDED)
|
||||
return;
|
||||
|
||||
spi = htonl(ntohs(ipch->cpi));
|
||||
|
@ -280,8 +280,8 @@ static int ipip_err(struct sk_buff *skb, u32 info)
|
||||
ICMP in the real Internet is absolutely infeasible.
|
||||
*/
|
||||
struct iphdr *iph = (struct iphdr*)skb->data;
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct ip_tunnel *t;
|
||||
int err;
|
||||
|
||||
@ -336,8 +336,8 @@ out:
|
||||
struct iphdr *iph = (struct iphdr*)dp;
|
||||
int hlen = iph->ihl<<2;
|
||||
struct iphdr *eiph;
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
int rel_type = 0;
|
||||
int rel_code = 0;
|
||||
__be32 rel_info = 0;
|
||||
@ -354,7 +354,7 @@ out:
|
||||
default:
|
||||
return 0;
|
||||
case ICMP_PARAMETERPROB:
|
||||
n = ntohl(skb->h.icmph->un.gateway) >> 24;
|
||||
n = ntohl(icmp_hdr(skb)->un.gateway) >> 24;
|
||||
if (n < hlen)
|
||||
return 0;
|
||||
|
||||
@ -373,7 +373,7 @@ out:
|
||||
return 0;
|
||||
case ICMP_FRAG_NEEDED:
|
||||
/* 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)
|
||||
return 0;
|
||||
n -= hlen;
|
||||
|
@ -132,7 +132,7 @@ static __inline__ int icmp_filter(struct sock *sk, struct sk_buff *skb)
|
||||
if (!pskb_may_pull(skb, sizeof(struct icmphdr)))
|
||||
return 1;
|
||||
|
||||
type = skb->h.icmph->type;
|
||||
type = icmp_hdr(skb)->type;
|
||||
if (type < 32) {
|
||||
__u32 data = raw_sk(sk)->filter.data;
|
||||
|
||||
@ -184,8 +184,8 @@ out:
|
||||
void raw_err (struct sock *sk, struct sk_buff *skb, u32 info)
|
||||
{
|
||||
struct inet_sock *inet = inet_sk(sk);
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
int err = 0;
|
||||
int harderr = 0;
|
||||
|
||||
|
@ -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 tcp_sock *tp;
|
||||
struct inet_sock *inet;
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct sock *sk;
|
||||
__u32 seq;
|
||||
int err;
|
||||
|
@ -330,8 +330,8 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[])
|
||||
struct inet_sock *inet;
|
||||
struct iphdr *iph = (struct iphdr*)skb->data;
|
||||
struct udphdr *uh = (struct udphdr*)(skb->data+(iph->ihl<<2));
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct sock *sk;
|
||||
int harderr;
|
||||
int err;
|
||||
|
@ -224,8 +224,8 @@ static int ipip6_err(struct sk_buff *skb, u32 info)
|
||||
ICMP in the real Internet is absolutely infeasible.
|
||||
*/
|
||||
struct iphdr *iph = (struct iphdr*)skb->data;
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct ip_tunnel *t;
|
||||
int err;
|
||||
|
||||
@ -280,8 +280,8 @@ out:
|
||||
struct iphdr *iph = (struct iphdr*)dp;
|
||||
int hlen = iph->ihl<<2;
|
||||
struct ipv6hdr *iph6;
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
int rel_type = 0;
|
||||
int rel_code = 0;
|
||||
int rel_info = 0;
|
||||
@ -296,14 +296,14 @@ out:
|
||||
default:
|
||||
return;
|
||||
case ICMP_PARAMETERPROB:
|
||||
if (skb->h.icmph->un.gateway < hlen)
|
||||
if (icmp_hdr(skb)->un.gateway < hlen)
|
||||
return;
|
||||
|
||||
/* So... This guy found something strange INSIDE encapsulated
|
||||
packet. Well, he is fool, but what can we do ?
|
||||
*/
|
||||
rel_type = ICMPV6_PARAMPROB;
|
||||
rel_info = skb->h.icmph->un.gateway - hlen;
|
||||
rel_info = icmp_hdr(skb)->un.gateway - hlen;
|
||||
break;
|
||||
|
||||
case ICMP_DEST_UNREACH:
|
||||
|
@ -507,8 +507,8 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
|
||||
{
|
||||
struct iphdr *iph = (struct iphdr *)skb->data;
|
||||
struct sctphdr *sh = (struct sctphdr *)(skb->data + (iph->ihl <<2));
|
||||
int type = skb->h.icmph->type;
|
||||
int code = skb->h.icmph->code;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct sock *sk;
|
||||
struct sctp_association *asoc = NULL;
|
||||
struct sctp_transport *transport;
|
||||
|
Loading…
Reference in New Issue
Block a user