[AF_PACKET]: annotate
Weirdness: the third argument of socket() is net-endian here. Oh, well - it's documented in packet(7). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3fbd418acc
commit
0e11c91e1e
|
@ -1,17 +1,19 @@
|
||||||
#ifndef __LINUX_IF_PACKET_H
|
#ifndef __LINUX_IF_PACKET_H
|
||||||
#define __LINUX_IF_PACKET_H
|
#define __LINUX_IF_PACKET_H
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
|
||||||
struct sockaddr_pkt
|
struct sockaddr_pkt
|
||||||
{
|
{
|
||||||
unsigned short spkt_family;
|
unsigned short spkt_family;
|
||||||
unsigned char spkt_device[14];
|
unsigned char spkt_device[14];
|
||||||
unsigned short spkt_protocol;
|
__be16 spkt_protocol;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sockaddr_ll
|
struct sockaddr_ll
|
||||||
{
|
{
|
||||||
unsigned short sll_family;
|
unsigned short sll_family;
|
||||||
unsigned short sll_protocol;
|
__be16 sll_protocol;
|
||||||
int sll_ifindex;
|
int sll_ifindex;
|
||||||
unsigned short sll_hatype;
|
unsigned short sll_hatype;
|
||||||
unsigned char sll_pkttype;
|
unsigned char sll_pkttype;
|
||||||
|
|
|
@ -201,7 +201,7 @@ struct packet_sock {
|
||||||
spinlock_t bind_lock;
|
spinlock_t bind_lock;
|
||||||
char running; /* prot_hook is attached*/
|
char running; /* prot_hook is attached*/
|
||||||
int ifindex; /* bound device */
|
int ifindex; /* bound device */
|
||||||
unsigned short num;
|
__be16 num;
|
||||||
#ifdef CONFIG_PACKET_MULTICAST
|
#ifdef CONFIG_PACKET_MULTICAST
|
||||||
struct packet_mclist *mclist;
|
struct packet_mclist *mclist;
|
||||||
#endif
|
#endif
|
||||||
|
@ -331,7 +331,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
|
||||||
struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name;
|
struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
unsigned short proto=0;
|
__be16 proto=0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -704,7 +704,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
|
||||||
struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name;
|
struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
unsigned short proto;
|
__be16 proto;
|
||||||
unsigned char *addr;
|
unsigned char *addr;
|
||||||
int ifindex, err, reserve = 0;
|
int ifindex, err, reserve = 0;
|
||||||
|
|
||||||
|
@ -858,7 +858,7 @@ static int packet_release(struct socket *sock)
|
||||||
* Attach a packet hook.
|
* Attach a packet hook.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int packet_do_bind(struct sock *sk, struct net_device *dev, int protocol)
|
static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protocol)
|
||||||
{
|
{
|
||||||
struct packet_sock *po = pkt_sk(sk);
|
struct packet_sock *po = pkt_sk(sk);
|
||||||
/*
|
/*
|
||||||
|
@ -983,6 +983,7 @@ static int packet_create(struct socket *sock, int protocol)
|
||||||
{
|
{
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
struct packet_sock *po;
|
struct packet_sock *po;
|
||||||
|
__be16 proto = (__force __be16)protocol; /* weird, but documented */
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!capable(CAP_NET_RAW))
|
if (!capable(CAP_NET_RAW))
|
||||||
|
@ -1010,7 +1011,7 @@ static int packet_create(struct socket *sock, int protocol)
|
||||||
|
|
||||||
po = pkt_sk(sk);
|
po = pkt_sk(sk);
|
||||||
sk->sk_family = PF_PACKET;
|
sk->sk_family = PF_PACKET;
|
||||||
po->num = protocol;
|
po->num = proto;
|
||||||
|
|
||||||
sk->sk_destruct = packet_sock_destruct;
|
sk->sk_destruct = packet_sock_destruct;
|
||||||
atomic_inc(&packet_socks_nr);
|
atomic_inc(&packet_socks_nr);
|
||||||
|
@ -1027,8 +1028,8 @@ static int packet_create(struct socket *sock, int protocol)
|
||||||
#endif
|
#endif
|
||||||
po->prot_hook.af_packet_priv = sk;
|
po->prot_hook.af_packet_priv = sk;
|
||||||
|
|
||||||
if (protocol) {
|
if (proto) {
|
||||||
po->prot_hook.type = protocol;
|
po->prot_hook.type = proto;
|
||||||
dev_add_pack(&po->prot_hook);
|
dev_add_pack(&po->prot_hook);
|
||||||
sock_hold(sk);
|
sock_hold(sk);
|
||||||
po->running = 1;
|
po->running = 1;
|
||||||
|
@ -1624,7 +1625,8 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing
|
||||||
{
|
{
|
||||||
char **pg_vec = NULL;
|
char **pg_vec = NULL;
|
||||||
struct packet_sock *po = pkt_sk(sk);
|
struct packet_sock *po = pkt_sk(sk);
|
||||||
int was_running, num, order = 0;
|
int was_running, order = 0;
|
||||||
|
__be16 num;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (req->tp_block_nr) {
|
if (req->tp_block_nr) {
|
||||||
|
|
Loading…
Reference in New Issue