Commit b963dc1d authored by Al Viro's avatar Al Viro Committed by David S. Miller

pppoe: endianness

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 53c03f5c
...@@ -103,7 +103,7 @@ static inline int cmp_2_addr(struct pppoe_addr *a, struct pppoe_addr *b) ...@@ -103,7 +103,7 @@ static inline int cmp_2_addr(struct pppoe_addr *a, struct pppoe_addr *b)
(memcmp(a->remote, b->remote, ETH_ALEN) == 0)); (memcmp(a->remote, b->remote, ETH_ALEN) == 0));
} }
static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr) static inline int cmp_addr(struct pppoe_addr *a, __be16 sid, char *addr)
{ {
return (a->sid == sid && return (a->sid == sid &&
(memcmp(a->remote,addr,ETH_ALEN) == 0)); (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,7 +113,7 @@ static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr)
#error 8 must be a multiple of PPPOE_HASH_BITS #error 8 must be a multiple of PPPOE_HASH_BITS
#endif #endif
static int hash_item(unsigned int sid, unsigned char *addr) static int hash_item(__be16 sid, unsigned char *addr)
{ {
unsigned char hash = 0; unsigned char hash = 0;
unsigned int i; unsigned int i;
...@@ -122,7 +122,7 @@ static int hash_item(unsigned int sid, unsigned char *addr) ...@@ -122,7 +122,7 @@ static int hash_item(unsigned int sid, unsigned char *addr)
hash ^= addr[i]; hash ^= addr[i];
} }
for (i = 0 ; i < sizeof(sid_t)*8 ; i += 8 ){ for (i = 0 ; i < sizeof(sid_t)*8 ; i += 8 ){
hash ^= sid>>i; hash ^= (__force __u32)sid>>i;
} }
for (i = 8 ; (i>>=1) >= PPPOE_HASH_BITS ; ) { for (i = 8 ; (i>>=1) >= PPPOE_HASH_BITS ; ) {
hash ^= hash>>i; hash ^= hash>>i;
...@@ -139,7 +139,7 @@ static struct pppox_sock *item_hash_table[PPPOE_HASH_SIZE]; ...@@ -139,7 +139,7 @@ static struct pppox_sock *item_hash_table[PPPOE_HASH_SIZE];
* Set/get/delete/rehash items (internal versions) * Set/get/delete/rehash items (internal versions)
* *
**********************************************************************/ **********************************************************************/
static struct pppox_sock *__get_item(unsigned long sid, unsigned char *addr, int ifindex) static struct pppox_sock *__get_item(__be16 sid, unsigned char *addr, int ifindex)
{ {
int hash = hash_item(sid, addr); int hash = hash_item(sid, addr);
struct pppox_sock *ret; struct pppox_sock *ret;
...@@ -171,7 +171,7 @@ static int __set_item(struct pppox_sock *po) ...@@ -171,7 +171,7 @@ static int __set_item(struct pppox_sock *po)
return 0; return 0;
} }
static struct pppox_sock *__delete_item(unsigned long sid, char *addr, int ifindex) static struct pppox_sock *__delete_item(__be16 sid, char *addr, int ifindex)
{ {
int hash = hash_item(sid, addr); int hash = hash_item(sid, addr);
struct pppox_sock *ret, **src; struct pppox_sock *ret, **src;
...@@ -197,7 +197,7 @@ static struct pppox_sock *__delete_item(unsigned long sid, char *addr, int ifind ...@@ -197,7 +197,7 @@ static struct pppox_sock *__delete_item(unsigned long sid, char *addr, int ifind
* Set/get/delete/rehash items * Set/get/delete/rehash items
* *
**********************************************************************/ **********************************************************************/
static inline struct pppox_sock *get_item(unsigned long sid, static inline struct pppox_sock *get_item(__be16 sid,
unsigned char *addr, int ifindex) unsigned char *addr, int ifindex)
{ {
struct pppox_sock *po; struct pppox_sock *po;
...@@ -224,7 +224,7 @@ static inline struct pppox_sock *get_item_by_addr(struct sockaddr_pppox *sp) ...@@ -224,7 +224,7 @@ static inline struct pppox_sock *get_item_by_addr(struct sockaddr_pppox *sp)
return get_item(sp->sa_addr.pppoe.sid, sp->sa_addr.pppoe.remote, ifindex); return get_item(sp->sa_addr.pppoe.sid, sp->sa_addr.pppoe.remote, ifindex);
} }
static inline struct pppox_sock *delete_item(unsigned long sid, char *addr, int ifindex) static inline struct pppox_sock *delete_item(__be16 sid, char *addr, int ifindex)
{ {
struct pppox_sock *ret; struct pppox_sock *ret;
...@@ -400,7 +400,7 @@ static int pppoe_rcv(struct sk_buff *skb, ...@@ -400,7 +400,7 @@ static int pppoe_rcv(struct sk_buff *skb,
ph = pppoe_hdr(skb); ph = pppoe_hdr(skb);
po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex); po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
if (po != NULL) if (po != NULL)
return sk_receive_skb(sk_pppox(po), skb, 0); return sk_receive_skb(sk_pppox(po), skb, 0);
drop: drop:
...@@ -437,7 +437,7 @@ static int pppoe_disc_rcv(struct sk_buff *skb, ...@@ -437,7 +437,7 @@ static int pppoe_disc_rcv(struct sk_buff *skb,
if (ph->code != PADT_CODE) if (ph->code != PADT_CODE)
goto abort; goto abort;
po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source, dev->ifindex); po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
if (po) { if (po) {
struct sock *sk = sk_pppox(po); struct sock *sk = sk_pppox(po);
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
/************************************************************************ /************************************************************************
* PPPoE addressing definition * PPPoE addressing definition
*/ */
typedef __u16 sid_t; typedef __be16 sid_t;
struct pppoe_addr{ struct pppoe_addr{
sid_t sid; /* Session identifier */ sid_t sid; /* Session identifier */
unsigned char remote[ETH_ALEN]; /* Remote address */ unsigned char remote[ETH_ALEN]; /* Remote address */
...@@ -90,8 +90,8 @@ struct sockaddr_pppol2tp { ...@@ -90,8 +90,8 @@ struct sockaddr_pppol2tp {
#define PADS_CODE 0x65 #define PADS_CODE 0x65
#define PADT_CODE 0xa7 #define PADT_CODE 0xa7
struct pppoe_tag { struct pppoe_tag {
__u16 tag_type; __be16 tag_type;
__u16 tag_len; __be16 tag_len;
char tag_data[0]; char tag_data[0];
} __attribute ((packed)); } __attribute ((packed));
...@@ -118,8 +118,8 @@ struct pppoe_hdr { ...@@ -118,8 +118,8 @@ struct pppoe_hdr {
#error "Please fix <asm/byteorder.h>" #error "Please fix <asm/byteorder.h>"
#endif #endif
__u8 code; __u8 code;
__u16 sid; __be16 sid;
__u16 length; __be16 length;
struct pppoe_tag tag[0]; struct pppoe_tag tag[0];
} __attribute__ ((packed)); } __attribute__ ((packed));
...@@ -152,7 +152,7 @@ struct pppox_sock { ...@@ -152,7 +152,7 @@ struct pppox_sock {
union { union {
struct pppoe_opt pppoe; struct pppoe_opt pppoe;
} proto; } proto;
unsigned short num; __be16 num;
}; };
#define pppoe_dev proto.pppoe.dev #define pppoe_dev proto.pppoe.dev
#define pppoe_ifindex proto.pppoe.ifindex #define pppoe_ifindex proto.pppoe.ifindex
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment