diff options
-rw-r--r-- | include/linux/if_packet.h | 6 | ||||
-rw-r--r-- | net/packet/af_packet.c | 18 |
2 files changed, 14 insertions, 10 deletions
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h index b92558549d27..99393ef3af39 100644 --- a/include/linux/if_packet.h +++ b/include/linux/if_packet.h | |||
@@ -1,17 +1,19 @@ | |||
1 | #ifndef __LINUX_IF_PACKET_H | 1 | #ifndef __LINUX_IF_PACKET_H |
2 | #define __LINUX_IF_PACKET_H | 2 | #define __LINUX_IF_PACKET_H |
3 | 3 | ||
4 | #include <linux/types.h> | ||
5 | |||
4 | struct sockaddr_pkt | 6 | struct sockaddr_pkt |
5 | { | 7 | { |
6 | unsigned short spkt_family; | 8 | unsigned short spkt_family; |
7 | unsigned char spkt_device[14]; | 9 | unsigned char spkt_device[14]; |
8 | unsigned short spkt_protocol; | 10 | __be16 spkt_protocol; |
9 | }; | 11 | }; |
10 | 12 | ||
11 | struct sockaddr_ll | 13 | struct sockaddr_ll |
12 | { | 14 | { |
13 | unsigned short sll_family; | 15 | unsigned short sll_family; |
14 | unsigned short sll_protocol; | 16 | __be16 sll_protocol; |
15 | int sll_ifindex; | 17 | int sll_ifindex; |
16 | unsigned short sll_hatype; | 18 | unsigned short sll_hatype; |
17 | unsigned char sll_pkttype; | 19 | unsigned char sll_pkttype; |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index f4ccb90e6739..271d2eed0699 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -201,7 +201,7 @@ struct packet_sock { | |||
201 | spinlock_t bind_lock; | 201 | spinlock_t bind_lock; |
202 | char running; /* prot_hook is attached*/ | 202 | char running; /* prot_hook is attached*/ |
203 | int ifindex; /* bound device */ | 203 | int ifindex; /* bound device */ |
204 | unsigned short num; | 204 | __be16 num; |
205 | #ifdef CONFIG_PACKET_MULTICAST | 205 | #ifdef CONFIG_PACKET_MULTICAST |
206 | struct packet_mclist *mclist; | 206 | struct packet_mclist *mclist; |
207 | #endif | 207 | #endif |
@@ -331,7 +331,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
331 | struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name; | 331 | struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name; |
332 | struct sk_buff *skb; | 332 | struct sk_buff *skb; |
333 | struct net_device *dev; | 333 | struct net_device *dev; |
334 | unsigned short proto=0; | 334 | __be16 proto=0; |
335 | int err; | 335 | int err; |
336 | 336 | ||
337 | /* | 337 | /* |
@@ -704,7 +704,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
704 | struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name; | 704 | struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name; |
705 | struct sk_buff *skb; | 705 | struct sk_buff *skb; |
706 | struct net_device *dev; | 706 | struct net_device *dev; |
707 | unsigned short proto; | 707 | __be16 proto; |
708 | unsigned char *addr; | 708 | unsigned char *addr; |
709 | int ifindex, err, reserve = 0; | 709 | int ifindex, err, reserve = 0; |
710 | 710 | ||
@@ -858,7 +858,7 @@ static int packet_release(struct socket *sock) | |||
858 | * Attach a packet hook. | 858 | * Attach a packet hook. |
859 | */ | 859 | */ |
860 | 860 | ||
861 | static int packet_do_bind(struct sock *sk, struct net_device *dev, int protocol) | 861 | static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protocol) |
862 | { | 862 | { |
863 | struct packet_sock *po = pkt_sk(sk); | 863 | struct packet_sock *po = pkt_sk(sk); |
864 | /* | 864 | /* |
@@ -983,6 +983,7 @@ static int packet_create(struct socket *sock, int protocol) | |||
983 | { | 983 | { |
984 | struct sock *sk; | 984 | struct sock *sk; |
985 | struct packet_sock *po; | 985 | struct packet_sock *po; |
986 | __be16 proto = (__force __be16)protocol; /* weird, but documented */ | ||
986 | int err; | 987 | int err; |
987 | 988 | ||
988 | if (!capable(CAP_NET_RAW)) | 989 | if (!capable(CAP_NET_RAW)) |
@@ -1010,7 +1011,7 @@ static int packet_create(struct socket *sock, int protocol) | |||
1010 | 1011 | ||
1011 | po = pkt_sk(sk); | 1012 | po = pkt_sk(sk); |
1012 | sk->sk_family = PF_PACKET; | 1013 | sk->sk_family = PF_PACKET; |
1013 | po->num = protocol; | 1014 | po->num = proto; |
1014 | 1015 | ||
1015 | sk->sk_destruct = packet_sock_destruct; | 1016 | sk->sk_destruct = packet_sock_destruct; |
1016 | atomic_inc(&packet_socks_nr); | 1017 | atomic_inc(&packet_socks_nr); |
@@ -1027,8 +1028,8 @@ static int packet_create(struct socket *sock, int protocol) | |||
1027 | #endif | 1028 | #endif |
1028 | po->prot_hook.af_packet_priv = sk; | 1029 | po->prot_hook.af_packet_priv = sk; |
1029 | 1030 | ||
1030 | if (protocol) { | 1031 | if (proto) { |
1031 | po->prot_hook.type = protocol; | 1032 | po->prot_hook.type = proto; |
1032 | dev_add_pack(&po->prot_hook); | 1033 | dev_add_pack(&po->prot_hook); |
1033 | sock_hold(sk); | 1034 | sock_hold(sk); |
1034 | po->running = 1; | 1035 | po->running = 1; |
@@ -1624,7 +1625,8 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing | |||
1624 | { | 1625 | { |
1625 | char **pg_vec = NULL; | 1626 | char **pg_vec = NULL; |
1626 | struct packet_sock *po = pkt_sk(sk); | 1627 | struct packet_sock *po = pkt_sk(sk); |
1627 | int was_running, num, order = 0; | 1628 | int was_running, order = 0; |
1629 | __be16 num; | ||
1628 | int err = 0; | 1630 | int err = 0; |
1629 | 1631 | ||
1630 | if (req->tp_block_nr) { | 1632 | if (req->tp_block_nr) { |