diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2007-08-23 02:55:33 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:04 -0400 |
commit | b963dc1df78399a2166c2e6e3eb726a2dc98cf11 (patch) | |
tree | 5a14d7d2cf9bebaaa1591c457fc30a42c3000b6d | |
parent | 53c03f5c9e3c05a2484ad6bb1d88c0aa54befa47 (diff) |
pppoe: endianness
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r-- | drivers/net/pppoe.c | 18 | ||||
-rw-r--r-- | include/linux/if_pppox.h | 12 |
2 files changed, 15 insertions, 15 deletions
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index ba2eb04aac9f..d48b7b73d896 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -103,7 +103,7 @@ static inline int cmp_2_addr(struct pppoe_addr *a, struct pppoe_addr *b) | |||
103 | (memcmp(a->remote, b->remote, ETH_ALEN) == 0)); | 103 | (memcmp(a->remote, b->remote, ETH_ALEN) == 0)); |
104 | } | 104 | } |
105 | 105 | ||
106 | static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr) | 106 | static inline int cmp_addr(struct pppoe_addr *a, __be16 sid, char *addr) |
107 | { | 107 | { |
108 | return (a->sid == sid && | 108 | return (a->sid == sid && |
109 | (memcmp(a->remote,addr,ETH_ALEN) == 0)); | 109 | (memcmp(a->remote,addr,ETH_ALEN) == 0)); |
@@ -113,7 +113,7 @@ static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr) | |||
113 | #error 8 must be a multiple of PPPOE_HASH_BITS | 113 | #error 8 must be a multiple of PPPOE_HASH_BITS |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | static int hash_item(unsigned int sid, unsigned char *addr) | 116 | static int hash_item(__be16 sid, unsigned char *addr) |
117 | { | 117 | { |
118 | unsigned char hash = 0; | 118 | unsigned char hash = 0; |
119 | unsigned int i; | 119 | unsigned int i; |
@@ -122,7 +122,7 @@ static int hash_item(unsigned int sid, unsigned char *addr) | |||
122 | hash ^= addr[i]; | 122 | hash ^= addr[i]; |
123 | } | 123 | } |
124 | for (i = 0 ; i < sizeof(sid_t)*8 ; i += 8 ){ | 124 | for (i = 0 ; i < sizeof(sid_t)*8 ; i += 8 ){ |
125 | hash ^= sid>>i; | 125 | hash ^= (__force __u32)sid>>i; |
126 | } | 126 | } |
127 | for (i = 8 ; (i>>=1) >= PPPOE_HASH_BITS ; ) { | 127 | for (i = 8 ; (i>>=1) >= PPPOE_HASH_BITS ; ) { |
128 | hash ^= hash>>i; | 128 | hash ^= hash>>i; |
@@ -139,7 +139,7 @@ static struct pppox_sock *item_hash_table[PPPOE_HASH_SIZE]; | |||
139 | * Set/get/delete/rehash items (internal versions) | 139 | * Set/get/delete/rehash items (internal versions) |
140 | * | 140 | * |
141 | **********************************************************************/ | 141 | **********************************************************************/ |
142 | static struct pppox_sock *__get_item(unsigned long sid, unsigned char *addr, int ifindex) | 142 | static struct pppox_sock *__get_item(__be16 sid, unsigned char *addr, int ifindex) |
143 | { | 143 | { |
144 | int hash = hash_item(sid, addr); | 144 | int hash = hash_item(sid, addr); |
145 | struct pppox_sock *ret; | 145 | struct pppox_sock *ret; |
@@ -171,7 +171,7 @@ static int __set_item(struct pppox_sock *po) | |||
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | static struct pppox_sock *__delete_item(unsigned long sid, char *addr, int ifindex) | 174 | static struct pppox_sock *__delete_item(__be16 sid, char *addr, int ifindex) |
175 | { | 175 | { |
176 | int hash = hash_item(sid, addr); | 176 | int hash = hash_item(sid, addr); |
177 | struct pppox_sock *ret, **src; | 177 | struct pppox_sock *ret, **src; |
@@ -197,7 +197,7 @@ static struct pppox_sock *__delete_item(unsigned long sid, char *addr, int ifind | |||
197 | * Set/get/delete/rehash items | 197 | * Set/get/delete/rehash items |
198 | * | 198 | * |
199 | **********************************************************************/ | 199 | **********************************************************************/ |
200 | static inline struct pppox_sock *get_item(unsigned long sid, | 200 | static inline struct pppox_sock *get_item(__be16 sid, |
201 | unsigned char *addr, int ifindex) | 201 | unsigned char *addr, int ifindex) |
202 | { | 202 | { |
203 | struct pppox_sock *po; | 203 | struct pppox_sock *po; |
@@ -224,7 +224,7 @@ static inline struct pppox_sock *get_item_by_addr(struct sockaddr_pppox *sp) | |||
224 | return get_item(sp->sa_addr.pppoe.sid, sp->sa_addr.pppoe.remote, ifindex); | 224 | return get_item(sp->sa_addr.pppoe.sid, sp->sa_addr.pppoe.remote, ifindex); |
225 | } | 225 | } |
226 | 226 | ||
227 | static inline struct pppox_sock *delete_item(unsigned long sid, char *addr, int ifindex) | 227 | static inline struct pppox_sock *delete_item(__be16 sid, char *addr, int ifindex) |
228 | { | 228 | { |
229 | struct pppox_sock *ret; | 229 | struct pppox_sock *ret; |
230 | 230 | ||
@@ -400,7 +400,7 @@ static int pppoe_rcv(struct sk_buff *skb, | |||
400 | 400 | ||
401 | ph = pppoe_hdr(skb); | 401 | ph = pppoe_hdr(skb); |
402 | 402 | ||
403 | po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex); | 403 | po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex); |
404 | if (po != NULL) | 404 | if (po != NULL) |
405 | return sk_receive_skb(sk_pppox(po), skb, 0); | 405 | return sk_receive_skb(sk_pppox(po), skb, 0); |
406 | drop: | 406 | drop: |
@@ -437,7 +437,7 @@ static int pppoe_disc_rcv(struct sk_buff *skb, | |||
437 | if (ph->code != PADT_CODE) | 437 | if (ph->code != PADT_CODE) |
438 | goto abort; | 438 | goto abort; |
439 | 439 | ||
440 | po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex); | 440 | po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex); |
441 | if (po) { | 441 | if (po) { |
442 | struct sock *sk = sk_pppox(po); | 442 | struct sock *sk = sk_pppox(po); |
443 | 443 | ||
diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h index 43cfc9f0c078..40743e032845 100644 --- a/include/linux/if_pppox.h +++ b/include/linux/if_pppox.h | |||
@@ -40,7 +40,7 @@ | |||
40 | /************************************************************************ | 40 | /************************************************************************ |
41 | * PPPoE addressing definition | 41 | * PPPoE addressing definition |
42 | */ | 42 | */ |
43 | typedef __u16 sid_t; | 43 | typedef __be16 sid_t; |
44 | struct pppoe_addr{ | 44 | struct pppoe_addr{ |
45 | sid_t sid; /* Session identifier */ | 45 | sid_t sid; /* Session identifier */ |
46 | unsigned char remote[ETH_ALEN]; /* Remote address */ | 46 | unsigned char remote[ETH_ALEN]; /* Remote address */ |
@@ -90,8 +90,8 @@ struct sockaddr_pppol2tp { | |||
90 | #define PADS_CODE 0x65 | 90 | #define PADS_CODE 0x65 |
91 | #define PADT_CODE 0xa7 | 91 | #define PADT_CODE 0xa7 |
92 | struct pppoe_tag { | 92 | struct pppoe_tag { |
93 | __u16 tag_type; | 93 | __be16 tag_type; |
94 | __u16 tag_len; | 94 | __be16 tag_len; |
95 | char tag_data[0]; | 95 | char tag_data[0]; |
96 | } __attribute ((packed)); | 96 | } __attribute ((packed)); |
97 | 97 | ||
@@ -118,8 +118,8 @@ struct pppoe_hdr { | |||
118 | #error "Please fix <asm/byteorder.h>" | 118 | #error "Please fix <asm/byteorder.h>" |
119 | #endif | 119 | #endif |
120 | __u8 code; | 120 | __u8 code; |
121 | __u16 sid; | 121 | __be16 sid; |
122 | __u16 length; | 122 | __be16 length; |
123 | struct pppoe_tag tag[0]; | 123 | struct pppoe_tag tag[0]; |
124 | } __attribute__ ((packed)); | 124 | } __attribute__ ((packed)); |
125 | 125 | ||
@@ -152,7 +152,7 @@ struct pppox_sock { | |||
152 | union { | 152 | union { |
153 | struct pppoe_opt pppoe; | 153 | struct pppoe_opt pppoe; |
154 | } proto; | 154 | } proto; |
155 | unsigned short num; | 155 | __be16 num; |
156 | }; | 156 | }; |
157 | #define pppoe_dev proto.pppoe.dev | 157 | #define pppoe_dev proto.pppoe.dev |
158 | #define pppoe_ifindex proto.pppoe.ifindex | 158 | #define pppoe_ifindex proto.pppoe.ifindex |