git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
net
/
ipv4
/
ip_gre.c
diff --git
a/net/ipv4/ip_gre.c
b/net/ipv4/ip_gre.c
index
9981dcd
..
476cb60
100644
(file)
--- a/
net/ipv4/ip_gre.c
+++ b/
net/ipv4/ip_gre.c
@@
-11,7
+11,6
@@
*/
#include <linux/capability.h>
*/
#include <linux/capability.h>
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/sched.h>
@@
-145,7
+144,7
@@
static struct net_device *ipgre_fb_tunnel_dev;
*/
#define HASH_SIZE 16
*/
#define HASH_SIZE 16
-#define HASH(addr) ((
addr^(
addr>>4))&0xF)
+#define HASH(addr) ((
(__force u32)addr^((__force u32)
addr>>4))&0xF)
static struct ip_tunnel *tunnels[4][HASH_SIZE];
static struct ip_tunnel *tunnels[4][HASH_SIZE];
@@
-158,7
+157,7
@@
static DEFINE_RWLOCK(ipgre_lock);
/* Given src, dst and key, find appropriate for input tunnel. */
/* Given src, dst and key, find appropriate for input tunnel. */
-static struct ip_tunnel * ipgre_tunnel_lookup(
u32 remote, u32 local, u
32 key)
+static struct ip_tunnel * ipgre_tunnel_lookup(
__be32 remote, __be32 local, __be
32 key)
{
unsigned h0 = HASH(remote);
unsigned h1 = HASH(key);
{
unsigned h0 = HASH(remote);
unsigned h1 = HASH(key);
@@
-195,9
+194,9
@@
static struct ip_tunnel * ipgre_tunnel_lookup(u32 remote, u32 local, u32 key)
static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
{
static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
{
-
u
32 remote = t->parms.iph.daddr;
-
u
32 local = t->parms.iph.saddr;
-
u
32 key = t->parms.i_key;
+
__be
32 remote = t->parms.iph.daddr;
+
__be
32 local = t->parms.iph.saddr;
+
__be
32 key = t->parms.i_key;
unsigned h = HASH(key);
int prio = 0;
unsigned h = HASH(key);
int prio = 0;
@@
-237,9
+236,9
@@
static void ipgre_tunnel_unlink(struct ip_tunnel *t)
static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int create)
{
static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int create)
{
-
u
32 remote = parms->iph.daddr;
-
u
32 local = parms->iph.saddr;
-
u
32 key = parms->i_key;
+
__be
32 remote = parms->iph.daddr;
+
__be
32 local = parms->iph.saddr;
+
__be
32 key = parms->i_key;
struct ip_tunnel *t, **tp, *nt;
struct net_device *dev;
unsigned h = HASH(key);
struct ip_tunnel *t, **tp, *nt;
struct net_device *dev;
unsigned h = HASH(key);
@@
-320,12
+319,12
@@
static void ipgre_err(struct sk_buff *skb, u32 info)
*/
struct iphdr *iph = (struct iphdr*)skb->data;
*/
struct iphdr *iph = (struct iphdr*)skb->data;
-
u16 *p = (u
16*)(skb->data+(iph->ihl<<2));
+
__be16 *p = (__be
16*)(skb->data+(iph->ihl<<2));
int grehlen = (iph->ihl<<2) + 4;
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
struct ip_tunnel *t;
int grehlen = (iph->ihl<<2) + 4;
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
struct ip_tunnel *t;
-
u
16 flags;
+
__be
16 flags;
flags = p[0];
if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) {
flags = p[0];
if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) {
@@
-371,7
+370,7
@@
static void ipgre_err(struct sk_buff *skb, u32 info)
}
read_lock(&ipgre_lock);
}
read_lock(&ipgre_lock);
- t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((
u
32*)p) + (grehlen>>2) - 1) : 0);
+ t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((
__be
32*)p) + (grehlen>>2) - 1) : 0);
if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr))
goto out;
if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr))
goto out;
@@
-389,13
+388,14
@@
out:
#else
struct iphdr *iph = (struct iphdr*)dp;
struct iphdr *eiph;
#else
struct iphdr *iph = (struct iphdr*)dp;
struct iphdr *eiph;
-
u16 *p = (u
16*)(dp+(iph->ihl<<2));
+
__be16 *p = (__be
16*)(dp+(iph->ihl<<2));
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
int rel_type = 0;
int rel_code = 0;
int type = skb->h.icmph->type;
int code = skb->h.icmph->code;
int rel_type = 0;
int rel_code = 0;
- int rel_info = 0;
- u16 flags;
+ __be32 rel_info = 0;
+ __u32 n = 0;
+ __be16 flags;
int grehlen = (iph->ihl<<2) + 4;
struct sk_buff *skb2;
struct flowi fl;
int grehlen = (iph->ihl<<2) + 4;
struct sk_buff *skb2;
struct flowi fl;
@@
-423,14
+423,16
@@
out:
default:
return;
case ICMP_PARAMETERPROB:
default:
return;
case ICMP_PARAMETERPROB:
- if (skb->h.icmph->un.gateway < (iph->ihl<<2))
+ n = ntohl(skb->h.icmph->un.gateway) >> 24;
+ if (n < (iph->ihl<<2))
return;
/* So... This guy found something strange INSIDE encapsulated
packet. Well, he is fool, but what can we do ?
*/
rel_type = ICMP_PARAMETERPROB;
return;
/* So... This guy found something strange INSIDE encapsulated
packet. Well, he is fool, but what can we do ?
*/
rel_type = ICMP_PARAMETERPROB;
- rel_info = skb->h.icmph->un.gateway - grehlen;
+ n -= grehlen;
+ rel_info = htonl(n << 24);
break;
case ICMP_DEST_UNREACH:
break;
case ICMP_DEST_UNREACH:
@@
-441,13
+443,14
@@
out:
return;
case ICMP_FRAG_NEEDED:
/* And it is the only really necessary thing :-) */
return;
case ICMP_FRAG_NEEDED:
/* And it is the only really necessary thing :-) */
-
rel_info
= ntohs(skb->h.icmph->un.frag.mtu);
- if (
rel_info
< grehlen+68)
+
n
= ntohs(skb->h.icmph->un.frag.mtu);
+ if (
n
< grehlen+68)
return;
return;
-
rel_info
-= grehlen;
+
n
-= grehlen;
/* BSD 4.2 MORE DOES NOT EXIST IN NATURE. */
/* BSD 4.2 MORE DOES NOT EXIST IN NATURE. */
- if (
rel_info
> ntohs(eiph->tot_len))
+ if (
n
> ntohs(eiph->tot_len))
return;
return;
+ rel_info = htonl(n);
break;
default:
/* All others are translated to HOST_UNREACH.
break;
default:
/* All others are translated to HOST_UNREACH.
@@
-509,12
+512,11
@@
out:
/* change mtu on this route */
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
/* change mtu on this route */
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
- if (
rel_info
> dst_mtu(skb2->dst)) {
+ if (
n
> dst_mtu(skb2->dst)) {
kfree_skb(skb2);
return;
}
kfree_skb(skb2);
return;
}
- skb2->dst->ops->update_pmtu(skb2->dst, rel_info);
- rel_info = htonl(rel_info);
+ skb2->dst->ops->update_pmtu(skb2->dst, n);
} else if (type == ICMP_TIME_EXCEEDED) {
struct ip_tunnel *t = netdev_priv(skb2->dev);
if (t->parms.iph.ttl) {
} else if (type == ICMP_TIME_EXCEEDED) {
struct ip_tunnel *t = netdev_priv(skb2->dev);
if (t->parms.iph.ttl) {
@@
-554,9
+556,9
@@
static int ipgre_rcv(struct sk_buff *skb)
{
struct iphdr *iph;
u8 *h;
{
struct iphdr *iph;
u8 *h;
-
u
16 flags;
-
u16
csum = 0;
-
u32
key = 0;
+
__be
16 flags;
+
__sum16
csum = 0;
+
__be32
key = 0;
u32 seqno = 0;
struct ip_tunnel *tunnel;
int offset = 4;
u32 seqno = 0;
struct ip_tunnel *tunnel;
int offset = 4;
@@
-566,7
+568,7
@@
static int ipgre_rcv(struct sk_buff *skb)
iph = skb->nh.iph;
h = skb->data;
iph = skb->nh.iph;
h = skb->data;
- flags = *(
u
16*)h;
+ flags = *(
__be
16*)h;
if (flags&(GRE_CSUM|GRE_KEY|GRE_ROUTING|GRE_SEQ|GRE_VERSION)) {
/* - Version must be 0.
if (flags&(GRE_CSUM|GRE_KEY|GRE_ROUTING|GRE_SEQ|GRE_VERSION)) {
/* - Version must be 0.
@@
-577,24
+579,24
@@
static int ipgre_rcv(struct sk_buff *skb)
if (flags&GRE_CSUM) {
switch (skb->ip_summed) {
if (flags&GRE_CSUM) {
switch (skb->ip_summed) {
- case CHECKSUM_
HW
:
- csum =
(u16)
csum_fold(skb->csum);
+ case CHECKSUM_
COMPLETE
:
+ csum = csum_fold(skb->csum);
if (!csum)
break;
/* fall through */
case CHECKSUM_NONE:
skb->csum = 0;
csum = __skb_checksum_complete(skb);
if (!csum)
break;
/* fall through */
case CHECKSUM_NONE:
skb->csum = 0;
csum = __skb_checksum_complete(skb);
- skb->ip_summed = CHECKSUM_
HW
;
+ skb->ip_summed = CHECKSUM_
COMPLETE
;
}
offset += 4;
}
if (flags&GRE_KEY) {
}
offset += 4;
}
if (flags&GRE_KEY) {
- key = *(
u
32*)(h + offset);
+ key = *(
__be
32*)(h + offset);
offset += 4;
}
if (flags&GRE_SEQ) {
offset += 4;
}
if (flags&GRE_SEQ) {
- seqno = ntohl(*(
u
32*)(h + offset));
+ seqno = ntohl(*(
__be
32*)(h + offset));
offset += 4;
}
}
offset += 4;
}
}
@@
-603,14
+605,14
@@
static int ipgre_rcv(struct sk_buff *skb)
if ((tunnel = ipgre_tunnel_lookup(iph->saddr, iph->daddr, key)) != NULL) {
secpath_reset(skb);
if ((tunnel = ipgre_tunnel_lookup(iph->saddr, iph->daddr, key)) != NULL) {
secpath_reset(skb);
- skb->protocol = *(
u
16*)(h + 2);
+ skb->protocol = *(
__be
16*)(h + 2);
/* WCCP version 1 and 2 protocol decoding.
* - Change protocol to IP
* - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
*/
if (flags == 0 &&
/* WCCP version 1 and 2 protocol decoding.
* - Change protocol to IP
* - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
*/
if (flags == 0 &&
- skb->protocol ==
__constant_
htons(ETH_P_WCCP)) {
- skb->protocol =
__constant_
htons(ETH_P_IP);
+ skb->protocol == htons(ETH_P_WCCP)) {
+ skb->protocol = htons(ETH_P_IP);
if ((*(h + offset) & 0xF0) != 0x40)
offset += 4;
}
if ((*(h + offset) & 0xF0) != 0x40)
offset += 4;
}
@@
-618,7
+620,6
@@
static int ipgre_rcv(struct sk_buff *skb)
skb->mac.raw = skb->nh.raw;
skb->nh.raw = __pskb_pull(skb, offset);
skb_postpull_rcsum(skb, skb->h.raw, offset);
skb->mac.raw = skb->nh.raw;
skb->nh.raw = __pskb_pull(skb, offset);
skb_postpull_rcsum(skb, skb->h.raw, offset);
- memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
skb->pkt_type = PACKET_HOST;
#ifdef CONFIG_NET_IPGRE_BROADCAST
if (MULTICAST(iph->daddr)) {
skb->pkt_type = PACKET_HOST;
#ifdef CONFIG_NET_IPGRE_BROADCAST
if (MULTICAST(iph->daddr)) {
@@
-656,7
+657,7
@@
static int ipgre_rcv(struct sk_buff *skb)
read_unlock(&ipgre_lock);
return(0);
}
read_unlock(&ipgre_lock);
return(0);
}
- icmp_send(skb, ICMP_DEST_UNREACH, ICMP_P
RO
T_UNREACH, 0);
+ icmp_send(skb, ICMP_DEST_UNREACH, ICMP_P
OR
T_UNREACH, 0);
drop:
read_unlock(&ipgre_lock);
drop:
read_unlock(&ipgre_lock);
@@
-672,13
+673,13
@@
static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
struct iphdr *old_iph = skb->nh.iph;
struct iphdr *tiph;
u8 tos;
struct iphdr *old_iph = skb->nh.iph;
struct iphdr *tiph;
u8 tos;
-
u16
df;
+
__be16
df;
struct rtable *rt; /* Route to the other host */
struct net_device *tdev; /* Device to other host */
struct iphdr *iph; /* Our new IP header */
int max_headroom; /* The extra header space needed */
int gre_hlen;
struct rtable *rt; /* Route to the other host */
struct net_device *tdev; /* Device to other host */
struct iphdr *iph; /* Our new IP header */
int max_headroom; /* The extra header space needed */
int gre_hlen;
-
u32
dst;
+
__be32
dst;
int mtu;
if (tunnel->recursion++) {
int mtu;
if (tunnel->recursion++) {
@@
-859,11
+860,11
@@
static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
}
iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
}
- ((
u
16*)(iph+1))[0] = tunnel->parms.o_flags;
- ((
u
16*)(iph+1))[1] = skb->protocol;
+ ((
__be
16*)(iph+1))[0] = tunnel->parms.o_flags;
+ ((
__be
16*)(iph+1))[1] = skb->protocol;
if (tunnel->parms.o_flags&(GRE_KEY|GRE_CSUM|GRE_SEQ)) {
if (tunnel->parms.o_flags&(GRE_KEY|GRE_CSUM|GRE_SEQ)) {
-
u32 *ptr = (u
32*)(((u8*)iph) + tunnel->hlen - 4);
+
__be32 *ptr = (__be
32*)(((u8*)iph) + tunnel->hlen - 4);
if (tunnel->parms.o_flags&GRE_SEQ) {
++tunnel->o_seqno;
if (tunnel->parms.o_flags&GRE_SEQ) {
++tunnel->o_seqno;
@@
-876,7
+877,7
@@
static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
}
if (tunnel->parms.o_flags&GRE_CSUM) {
*ptr = 0;
}
if (tunnel->parms.o_flags&GRE_CSUM) {
*ptr = 0;
- *(__
u
16*)ptr = ip_compute_csum((void*)(iph+1), skb->len - sizeof(struct iphdr));
+ *(__
sum
16*)ptr = ip_compute_csum((void*)(iph+1), skb->len - sizeof(struct iphdr));
}
}
}
}
@@
-1067,7
+1068,7
@@
static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned sh
{
struct ip_tunnel *t = netdev_priv(dev);
struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen);
{
struct ip_tunnel *t = netdev_priv(dev);
struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen);
-
u16 *p = (u
16*)(iph+1);
+
__be16 *p = (__be
16*)(iph+1);
memcpy(iph, &t->parms.iph, sizeof(struct iphdr));
p[0] = t->parms.o_flags;
memcpy(iph, &t->parms.iph, sizeof(struct iphdr));
p[0] = t->parms.o_flags;