From 8dc4194474159660d7f37c495e3fc3f10d0db8cc Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sun, 4 Feb 2007 23:31:32 -0800 Subject: [PACKET]: Add optional checksum computation for recvmsg This patch is needed to make ISC's DHCP server (and probably other DHCP servers/clients using AF_PACKET) to be able to serve another client on the same Xen host. The problem is that packets between different domains on the same Xen host only have partial checksums. Unfortunately this piece of information is not passed along in AF_PACKET unless you're using the mmap interface. Since dhcpd doesn't support packet-mmap, UDP packets from the same host come out with apparently bogus checksums. This patch adds a mechanism for AF_PACKET recvmsg(2) to return the status along with the packet. It does so by adding a new cmsg that contains this information along with some other relevant data such as the original packet length. I didn't include the time stamp information since there is already a cmsg for that. This patch also changes the mmap code to set the CSUMNOTREADY flag on all packets instead of just outoing packets on cooked sockets. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- net/packet/af_packet.c | 57 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 9 deletions(-) (limited to 'net/packet/af_packet.c') diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 6dc01bdeb76..8973ea78831 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -200,7 +200,8 @@ struct packet_sock { #endif struct packet_type prot_hook; spinlock_t bind_lock; - char running; /* prot_hook is attached*/ + unsigned int running:1, /* prot_hook is attached*/ + auxdata:1; int ifindex; /* bound device */ __be16 num; #ifdef CONFIG_PACKET_MULTICAST @@ -214,6 +215,8 @@ struct packet_sock { #endif }; +#define PACKET_SKB_CB(__skb) ((struct tpacket_auxdata *)((__skb)->cb)) + #ifdef CONFIG_PACKET_MMAP static inline char *packet_lookup_frame(struct packet_sock *po, unsigned int position) @@ -462,6 +465,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet u8 * skb_head = skb->data; int skb_len = skb->len; unsigned int snaplen, res; + struct tpacket_auxdata *aux; if (skb->pkt_type == PACKET_LOOPBACK) goto drop; @@ -523,6 +527,15 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet if (dev->hard_header_parse) sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr); + aux = PACKET_SKB_CB(skb); + aux->tp_status = TP_STATUS_USER; + if (skb->ip_summed == CHECKSUM_PARTIAL) + aux->tp_status |= TP_STATUS_CSUMNOTREADY; + aux->tp_len = skb->len; + aux->tp_snaplen = snaplen; + aux->tp_mac = 0; + aux->tp_net = skb->nh.raw - skb->data; + if (pskb_trim(skb, snaplen)) goto drop_n_acct; @@ -582,11 +595,12 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe else if (skb->pkt_type == PACKET_OUTGOING) { /* Special case: outgoing packets have ll header at head */ skb_pull(skb, skb->nh.raw - skb->data); - if (skb->ip_summed == CHECKSUM_PARTIAL) - status |= TP_STATUS_CSUMNOTREADY; } } + if (skb->ip_summed == CHECKSUM_PARTIAL) + status |= TP_STATUS_CSUMNOTREADY; + snaplen = skb->len; res = run_filter(skb, sk, snaplen); @@ -1119,6 +1133,11 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, if (msg->msg_name) memcpy(msg->msg_name, skb->cb, msg->msg_namelen); + if (pkt_sk(sk)->auxdata) { + struct tpacket_auxdata *aux = PACKET_SKB_CB(skb); + put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(*aux), aux); + } + /* * Free or return the buffer as appropriate. Again this * hides all the races and re-entrancy issues from us. @@ -1317,6 +1336,7 @@ static int packet_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen) { struct sock *sk = sock->sk; + struct packet_sock *po = pkt_sk(sk); int ret; if (level != SOL_PACKET) @@ -1369,6 +1389,18 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv return 0; } #endif + case PACKET_AUXDATA: + { + int val; + + if (optlen < sizeof(val)) + return -EINVAL; + if (copy_from_user(&val, optval, sizeof(val))) + return -EFAULT; + + po->auxdata = !!val; + return 0; + } default: return -ENOPROTOOPT; } @@ -1378,8 +1410,11 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen) { int len; + int val; struct sock *sk = sock->sk; struct packet_sock *po = pkt_sk(sk); + void *data; + struct tpacket_stats st; if (level != SOL_PACKET) return -ENOPROTOOPT; @@ -1392,9 +1427,6 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, switch(optname) { case PACKET_STATISTICS: - { - struct tpacket_stats st; - if (len > sizeof(struct tpacket_stats)) len = sizeof(struct tpacket_stats); spin_lock_bh(&sk->sk_receive_queue.lock); @@ -1403,16 +1435,23 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, spin_unlock_bh(&sk->sk_receive_queue.lock); st.tp_packets += st.tp_drops; - if (copy_to_user(optval, &st, len)) - return -EFAULT; + data = &st; + break; + case PACKET_AUXDATA: + if (len > sizeof(int)) + len = sizeof(int); + val = po->auxdata; + + data = &val; break; - } default: return -ENOPROTOOPT; } if (put_user(len, optlen)) return -EFAULT; + if (copy_to_user(optval, data, len)) + return -EFAULT; return 0; } -- cgit v1.2.3-70-g09d2 From ffbc61117d32dc4e768f999325ecfb2528d6b303 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sun, 4 Feb 2007 23:33:10 -0800 Subject: [PACKET]: Fix skb->cb clobbering between aux and sockaddr Both aux data and sockaddr tries to use the same buffer which obviously doesn't work. We just happen to have 4 bytes free in the skb->cb if you take away the maximum length of sockaddr_ll. That's just enough to store the one piece of info from aux data that we can't generate at recvmsg(2) time. This is what the following patch does. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- net/packet/af_packet.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'net/packet/af_packet.c') diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 8973ea78831..a6fa48788e8 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -215,7 +216,15 @@ struct packet_sock { #endif }; -#define PACKET_SKB_CB(__skb) ((struct tpacket_auxdata *)((__skb)->cb)) +struct packet_skb_cb { + unsigned int origlen; + union { + struct sockaddr_pkt pkt; + struct sockaddr_ll ll; + } sa; +}; + +#define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb)) #ifdef CONFIG_PACKET_MMAP @@ -296,7 +305,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct /* drop conntrack reference */ nf_reset(skb); - spkt = (struct sockaddr_pkt*)skb->cb; + spkt = &PACKET_SKB_CB(skb)->sa.pkt; skb_push(skb, skb->data-skb->mac.raw); @@ -465,7 +474,6 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet u8 * skb_head = skb->data; int skb_len = skb->len; unsigned int snaplen, res; - struct tpacket_auxdata *aux; if (skb->pkt_type == PACKET_LOOPBACK) goto drop; @@ -516,7 +524,10 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet skb = nskb; } - sll = (struct sockaddr_ll*)skb->cb; + BUILD_BUG_ON(sizeof(*PACKET_SKB_CB(skb)) + MAX_ADDR_LEN - 8 > + sizeof(skb->cb)); + + sll = &PACKET_SKB_CB(skb)->sa.ll; sll->sll_family = AF_PACKET; sll->sll_hatype = dev->type; sll->sll_protocol = skb->protocol; @@ -527,14 +538,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet if (dev->hard_header_parse) sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr); - aux = PACKET_SKB_CB(skb); - aux->tp_status = TP_STATUS_USER; - if (skb->ip_summed == CHECKSUM_PARTIAL) - aux->tp_status |= TP_STATUS_CSUMNOTREADY; - aux->tp_len = skb->len; - aux->tp_snaplen = snaplen; - aux->tp_mac = 0; - aux->tp_net = skb->nh.raw - skb->data; + PACKET_SKB_CB(skb)->origlen = skb->len; if (pskb_trim(skb, snaplen)) goto drop_n_acct; @@ -1106,7 +1110,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, * it in now. */ - sll = (struct sockaddr_ll*)skb->cb; + sll = &PACKET_SKB_CB(skb)->sa.ll; if (sock->type == SOCK_PACKET) msg->msg_namelen = sizeof(struct sockaddr_pkt); else @@ -1131,11 +1135,21 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, sock_recv_timestamp(msg, sk, skb); if (msg->msg_name) - memcpy(msg->msg_name, skb->cb, msg->msg_namelen); + memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa, + msg->msg_namelen); if (pkt_sk(sk)->auxdata) { - struct tpacket_auxdata *aux = PACKET_SKB_CB(skb); - put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(*aux), aux); + struct tpacket_auxdata aux; + + aux.tp_status = TP_STATUS_USER; + if (skb->ip_summed == CHECKSUM_PARTIAL) + aux.tp_status |= TP_STATUS_CSUMNOTREADY; + aux.tp_len = PACKET_SKB_CB(skb)->origlen; + aux.tp_snaplen = skb->len; + aux.tp_mac = 0; + aux.tp_net = skb->nh.raw - skb->data; + + put_cmsg(msg, SOL_PACKET, PACKET_AUXDATA, sizeof(aux), &aux); } /* -- cgit v1.2.3-70-g09d2 From 1ce4f28bd761eeb979d29be350f2d22383d4c2f0 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Fri, 9 Feb 2007 23:25:10 +0900 Subject: [NET] PACKET: Fix whitespace errors. Signed-off-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- net/packet/af_packet.c | 78 +++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'net/packet/af_packet.c') diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index a6fa48788e8..444550917bc 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -11,7 +11,7 @@ * Fred N. van Kempen, * Alan Cox, * - * Fixes: + * Fixes: * Alan Cox : verify_area() now used correctly * Alan Cox : new skbuff lists, look ma no backlogs! * Alan Cox : tidied skbuff lists. @@ -34,12 +34,12 @@ * Alexey Kuznetsov : Untied from IPv4 stack. * Cyrus Durgin : Fixed kerneld for kmod. * Michal Ostrowski : Module initialization cleanup. - * Ulises Alonso : Frame number limit removal and + * Ulises Alonso : Frame number limit removal and * packet_set_ring memory leak. * Eric Biederman : Allow for > 8 byte hardware addresses. * The convention is that longer addresses * will simply extend the hardware address - * byte arrays at the end of sockaddr_ll + * byte arrays at the end of sockaddr_ll * and packet_mreq. * * This program is free software; you can redistribute it and/or @@ -48,7 +48,7 @@ * 2 of the License, or (at your option) any later version. * */ - + #include #include #include @@ -124,7 +124,7 @@ Outgoing, dev->hard_header!=NULL Incoming, dev->hard_header==NULL mac.raw -> UNKNOWN position. It is very likely, that it points to ll header. - PPP makes it, that is wrong, because introduce assymetry + PPP makes it, that is wrong, because introduce assymetry between rx and tx paths. data -> data @@ -237,7 +237,7 @@ static inline char *packet_lookup_frame(struct packet_sock *po, unsigned int pos frame_offset = position % po->frames_per_block; frame = po->pg_vec[pg_vec_pos] + (frame_offset * po->frame_size); - + return frame; } #endif @@ -280,7 +280,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct */ sk = pt->af_packet_priv; - + /* * Yank back the headers [hope the device set this * right or kerboom...] @@ -336,7 +336,7 @@ oom: * Output a raw packet to a device layer. This bypasses all the other * protocol layers and you must therefore supply it with a complete frame */ - + static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len) { @@ -346,9 +346,9 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, struct net_device *dev; __be16 proto=0; int err; - + /* - * Get and verify the address. + * Get and verify the address. */ if (saddr) @@ -362,7 +362,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, return(-ENOTCONN); /* SOCK_PACKET must be sent giving an address */ /* - * Find the device first to size check it + * Find the device first to size check it */ saddr->spkt_device[13] = 0; @@ -370,7 +370,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, err = -ENODEV; if (dev == NULL) goto out_unlock; - + err = -ENETDOWN; if (!(dev->flags & IFF_UP)) goto out_unlock; @@ -379,7 +379,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, * You may not queue a frame bigger than the mtu. This is the lowest level * raw protocol and you must do your own fragmentation at this level. */ - + err = -EMSGSIZE; if (len > dev->mtu + dev->hard_header_len) goto out_unlock; @@ -392,14 +392,14 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, * deal with the problem - do your own algorithmic backoffs. That's far * more flexible. */ - - if (skb == NULL) + + if (skb == NULL) goto out_unlock; /* - * Fill it in + * Fill it in */ - + /* FIXME: Save some space for broken drivers that write a * hard header at transmission time by themselves. PPP is the * notable one here. This should really be fixed at the driver level. @@ -641,7 +641,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe spin_lock(&sk->sk_receive_queue.lock); h = (struct tpacket_hdr *)packet_lookup_frame(po, po->head); - + if (h->tp_status) goto ring_is_full; po->head = po->head != po->frame_max ? po->head+1 : 0; @@ -660,7 +660,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe h->tp_snaplen = snaplen; h->tp_mac = macoff; h->tp_net = netoff; - if (skb->tstamp.off_sec == 0) { + if (skb->tstamp.off_sec == 0) { __net_timestamp(skb); sock_enable_timestamp(sk); } @@ -700,7 +700,7 @@ drop_n_restore: skb->len = skb_len; } drop: - kfree_skb(skb); + kfree_skb(skb); return 0; ring_is_full: @@ -728,9 +728,9 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, int ifindex, err, reserve = 0; /* - * Get and verify the address. + * Get and verify the address. */ - + if (saddr == NULL) { struct packet_sock *po = pkt_sk(sk); @@ -939,11 +939,11 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add char name[15]; struct net_device *dev; int err = -ENODEV; - + /* * Check legality */ - + if (addr_len != sizeof(struct sockaddr)) return -EINVAL; strlcpy(name,uaddr->sa_data,sizeof(name)); @@ -968,7 +968,7 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len /* * Check legality */ - + if (addr_len < sizeof(struct sockaddr_ll)) return -EINVAL; if (sll->sll_family != AF_PACKET) @@ -995,7 +995,7 @@ static struct proto packet_proto = { }; /* - * Create a packet of type SOCK_PACKET. + * Create a packet of type SOCK_PACKET. */ static int packet_create(struct socket *sock, int protocol) @@ -1097,7 +1097,7 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock, skb=skb_recv_datagram(sk,flags,flags&MSG_DONTWAIT,&err); /* - * An error occurred so return it. Because skb_recv_datagram() + * An error occurred so return it. Because skb_recv_datagram() * handles the blocking we don't see and worry about blocking * retries. */ @@ -1358,7 +1358,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv switch(optname) { #ifdef CONFIG_PACKET_MULTICAST - case PACKET_ADD_MEMBERSHIP: + case PACKET_ADD_MEMBERSHIP: case PACKET_DROP_MEMBERSHIP: { struct packet_mreq_max mreq; @@ -1438,7 +1438,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, if (len < 0) return -EINVAL; - + switch(optname) { case PACKET_STATISTICS: if (len > sizeof(struct tpacket_stats)) @@ -1547,7 +1547,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd, } case SIOCGSTAMP: return sock_get_timestamp(sk, (struct timeval __user *)arg); - + #ifdef CONFIG_INET case SIOCADDRT: case SIOCDELRT: @@ -1608,7 +1608,7 @@ static void packet_mm_open(struct vm_area_struct *vma) struct file *file = vma->vm_file; struct socket * sock = file->private_data; struct sock *sk = sock->sk; - + if (sk) atomic_inc(&pkt_sk(sk)->mapped); } @@ -1618,7 +1618,7 @@ static void packet_mm_close(struct vm_area_struct *vma) struct file *file = vma->vm_file; struct socket * sock = file->private_data; struct sock *sk = sock->sk; - + if (sk) atomic_dec(&pkt_sk(sk)->mapped); } @@ -1682,7 +1682,7 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing int was_running, order = 0; __be16 num; int err = 0; - + if (req->tp_block_nr) { int i, l; @@ -1744,7 +1744,7 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing __sock_put(sk); } spin_unlock(&po->bind_lock); - + synchronize_net(); err = -EBUSY; @@ -1861,7 +1861,7 @@ static const struct proto_ops packet_ops = { .connect = sock_no_connect, .socketpair = sock_no_socketpair, .accept = sock_no_accept, - .getname = packet_getname, + .getname = packet_getname, .poll = packet_poll, .ioctl = packet_ioctl, .listen = sock_no_listen, @@ -1906,17 +1906,17 @@ static void *packet_seq_start(struct seq_file *seq, loff_t *pos) static void *packet_seq_next(struct seq_file *seq, void *v, loff_t *pos) { ++*pos; - return (v == SEQ_START_TOKEN) - ? sk_head(&packet_sklist) + return (v == SEQ_START_TOKEN) + ? sk_head(&packet_sklist) : sk_next((struct sock*)v) ; } static void packet_seq_stop(struct seq_file *seq, void *v) { - read_unlock(&packet_sklist_lock); + read_unlock(&packet_sklist_lock); } -static int packet_seq_show(struct seq_file *seq, void *v) +static int packet_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) seq_puts(seq, "sk RefCnt Type Proto Iface R Rmem User Inode\n"); -- cgit v1.2.3-70-g09d2 From da7071d7e32d15149cc513f096a3638097b66387 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 12 Feb 2007 00:55:36 -0800 Subject: [PATCH] mark struct file_operations const 8 Many struct file_operations in the kernel can be "const". Marking them const moves these to the .rodata section, which avoids false sharing with potential dirty data. In addition it'll catch accidental writes at compile time to these shared resources. Signed-off-by: Arjan van de Ven Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/irda/ircomm/ircomm_core.c | 2 +- net/irda/iriap.c | 2 +- net/irda/irlan/irlan_common.c | 2 +- net/irda/irlap.c | 2 +- net/irda/irlmp.c | 2 +- net/irda/irttp.c | 2 +- net/llc/llc_proc.c | 4 ++-- net/netfilter/nf_conntrack_expect.c | 2 +- net/netfilter/nf_conntrack_standalone.c | 4 ++-- net/netfilter/nf_log.c | 2 +- net/netfilter/nf_queue.c | 2 +- net/netfilter/nfnetlink_log.c | 2 +- net/netfilter/nfnetlink_queue.c | 2 +- net/netfilter/x_tables.c | 2 +- net/netfilter/xt_hashlimit.c | 4 ++-- net/netlink/af_netlink.c | 2 +- net/netrom/af_netrom.c | 2 +- net/netrom/nr_route.c | 4 ++-- net/packet/af_packet.c | 2 +- net/rose/af_rose.c | 2 +- net/rose/rose_route.c | 6 +++--- net/rxrpc/proc.c | 8 ++++---- net/sched/sch_api.c | 2 +- net/sctp/proc.c | 6 +++--- net/socket.c | 2 +- net/sunrpc/cache.c | 12 ++++++------ net/sunrpc/rpc_pipe.c | 4 ++-- net/sunrpc/stats.c | 2 +- net/unix/af_unix.c | 2 +- net/wanrouter/wanproc.c | 6 +++--- net/x25/x25_proc.c | 4 ++-- 31 files changed, 51 insertions(+), 51 deletions(-) (limited to 'net/packet/af_packet.c') diff --git a/net/irda/ircomm/ircomm_core.c b/net/irda/ircomm/ircomm_core.c index c28ee7bce26..ec40715dcdd 100644 --- a/net/irda/ircomm/ircomm_core.c +++ b/net/irda/ircomm/ircomm_core.c @@ -56,7 +56,7 @@ static void ircomm_control_indication(struct ircomm_cb *self, extern struct proc_dir_entry *proc_irda; static int ircomm_seq_open(struct inode *, struct file *); -static struct file_operations ircomm_proc_fops = { +static const struct file_operations ircomm_proc_fops = { .owner = THIS_MODULE, .open = ircomm_seq_open, .read = seq_read, diff --git a/net/irda/iriap.c b/net/irda/iriap.c index 98b0fa96579..915d9384f36 100644 --- a/net/irda/iriap.c +++ b/net/irda/iriap.c @@ -1080,7 +1080,7 @@ static int irias_seq_open(struct inode *inode, struct file *file) return seq_open(file, &irias_seq_ops); } -struct file_operations irias_seq_fops = { +const struct file_operations irias_seq_fops = { .owner = THIS_MODULE, .open = irias_seq_open, .read = seq_read, diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c index 9c3dc57ff74..fcf9d659962 100644 --- a/net/irda/irlan/irlan_common.c +++ b/net/irda/irlan/irlan_common.c @@ -93,7 +93,7 @@ extern struct proc_dir_entry *proc_irda; static int irlan_seq_open(struct inode *inode, struct file *file); -static struct file_operations irlan_fops = { +static const struct file_operations irlan_fops = { .owner = THIS_MODULE, .open = irlan_seq_open, .read = seq_read, diff --git a/net/irda/irlap.c b/net/irda/irlap.c index fd73e4af715..d93ebd11431 100644 --- a/net/irda/irlap.c +++ b/net/irda/irlap.c @@ -1244,7 +1244,7 @@ out_kfree: goto out; } -struct file_operations irlap_seq_fops = { +const struct file_operations irlap_seq_fops = { .owner = THIS_MODULE, .open = irlap_seq_open, .read = seq_read, diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c index b134c3cf2bd..9df0461b6d1 100644 --- a/net/irda/irlmp.c +++ b/net/irda/irlmp.c @@ -2026,7 +2026,7 @@ out_kfree: goto out; } -struct file_operations irlmp_seq_fops = { +const struct file_operations irlmp_seq_fops = { .owner = THIS_MODULE, .open = irlmp_seq_open, .read = seq_read, diff --git a/net/irda/irttp.c b/net/irda/irttp.c index 68836358fdf..a7486b3bddc 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c @@ -1895,7 +1895,7 @@ out_kfree: goto out; } -struct file_operations irttp_seq_fops = { +const struct file_operations irttp_seq_fops = { .owner = THIS_MODULE, .open = irttp_seq_open, .read = seq_read, diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c index dcfe6c73947..3ab9d9f8b17 100644 --- a/net/llc/llc_proc.c +++ b/net/llc/llc_proc.c @@ -208,7 +208,7 @@ static int llc_seq_core_open(struct inode *inode, struct file *file) return seq_open(file, &llc_seq_core_ops); } -static struct file_operations llc_seq_socket_fops = { +static const struct file_operations llc_seq_socket_fops = { .owner = THIS_MODULE, .open = llc_seq_socket_open, .read = seq_read, @@ -216,7 +216,7 @@ static struct file_operations llc_seq_socket_fops = { .release = seq_release, }; -static struct file_operations llc_seq_core_fops = { +static const struct file_operations llc_seq_core_fops = { .owner = THIS_MODULE, .open = llc_seq_core_open, .read = seq_read, diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index 9cbf926cdd1..5cdcd7f4e81 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c @@ -435,7 +435,7 @@ static int exp_open(struct inode *inode, struct file *file) return seq_open(file, &exp_seq_ops); } -struct file_operations exp_file_ops = { +const struct file_operations exp_file_ops = { .owner = THIS_MODULE, .open = exp_open, .read = seq_read, diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index f1cb60ff931..04ac12431db 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c @@ -229,7 +229,7 @@ out_free: return ret; } -static struct file_operations ct_file_ops = { +static const struct file_operations ct_file_ops = { .owner = THIS_MODULE, .open = ct_open, .read = seq_read, @@ -317,7 +317,7 @@ static int ct_cpu_seq_open(struct inode *inode, struct file *file) return seq_open(file, &ct_cpu_seq_ops); } -static struct file_operations ct_cpu_seq_fops = { +static const struct file_operations ct_cpu_seq_fops = { .owner = THIS_MODULE, .open = ct_cpu_seq_open, .read = seq_read, diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c index 8901b3a07f7..07e28e08961 100644 --- a/net/netfilter/nf_log.c +++ b/net/netfilter/nf_log.c @@ -151,7 +151,7 @@ static int nflog_open(struct inode *inode, struct file *file) return seq_open(file, &nflog_seq_ops); } -static struct file_operations nflog_file_ops = { +static const struct file_operations nflog_file_ops = { .owner = THIS_MODULE, .open = nflog_open, .read = seq_read, diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c index 4d8936ed581..e136fea1db2 100644 --- a/net/netfilter/nf_queue.c +++ b/net/netfilter/nf_queue.c @@ -331,7 +331,7 @@ static int nfqueue_open(struct inode *inode, struct file *file) return seq_open(file, &nfqueue_seq_ops); } -static struct file_operations nfqueue_file_ops = { +static const struct file_operations nfqueue_file_ops = { .owner = THIS_MODULE, .open = nfqueue_open, .read = seq_read, diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index d1505dd25c6..c47e7e2ba64 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -1025,7 +1025,7 @@ out_free: return ret; } -static struct file_operations nful_file_ops = { +static const struct file_operations nful_file_ops = { .owner = THIS_MODULE, .open = nful_open, .read = seq_read, diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index a88a017da22..99e516eca41 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -1077,7 +1077,7 @@ out_free: return ret; } -static struct file_operations nfqnl_file_ops = { +static const struct file_operations nfqnl_file_ops = { .owner = THIS_MODULE, .open = nfqnl_open, .read = seq_read, diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 8996584b849..134cc88f8c8 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -772,7 +772,7 @@ static int xt_tgt_open(struct inode *inode, struct file *file) return ret; } -static struct file_operations xt_file_ops = { +static const struct file_operations xt_file_ops = { .owner = THIS_MODULE, .open = xt_tgt_open, .read = seq_read, diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index bd1f7a2048d..269a1e79347 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -37,7 +37,7 @@ MODULE_ALIAS("ip6t_hashlimit"); /* need to declare this at the top */ static struct proc_dir_entry *hashlimit_procdir4; static struct proc_dir_entry *hashlimit_procdir6; -static struct file_operations dl_file_ops; +static const struct file_operations dl_file_ops; /* hash table crap */ struct dsthash_dst { @@ -714,7 +714,7 @@ static int dl_proc_open(struct inode *inode, struct file *file) return ret; } -static struct file_operations dl_file_ops = { +static const struct file_operations dl_file_ops = { .owner = THIS_MODULE, .open = dl_proc_open, .read = seq_read, diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index f6ee9b47428..e73d8f546c6 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1713,7 +1713,7 @@ static int netlink_seq_open(struct inode *inode, struct file *file) return 0; } -static struct file_operations netlink_seq_fops = { +static const struct file_operations netlink_seq_fops = { .owner = THIS_MODULE, .open = netlink_seq_open, .read = seq_read, diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 799b76806bc..bf9837dd95c 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -1335,7 +1335,7 @@ static int nr_info_open(struct inode *inode, struct file *file) return seq_open(file, &nr_info_seqops); } -static struct file_operations nr_info_fops = { +static const struct file_operations nr_info_fops = { .owner = THIS_MODULE, .open = nr_info_open, .read = seq_read, diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index e9909aeb43e..c2fbac9c69c 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -934,7 +934,7 @@ static int nr_node_info_open(struct inode *inode, struct file *file) return seq_open(file, &nr_node_seqops); } -struct file_operations nr_nodes_fops = { +const struct file_operations nr_nodes_fops = { .owner = THIS_MODULE, .open = nr_node_info_open, .read = seq_read, @@ -1018,7 +1018,7 @@ static int nr_neigh_info_open(struct inode *inode, struct file *file) return seq_open(file, &nr_neigh_seqops); } -struct file_operations nr_neigh_fops = { +const struct file_operations nr_neigh_fops = { .owner = THIS_MODULE, .open = nr_neigh_info_open, .read = seq_read, diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 444550917bc..15ff7b15e21 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1952,7 +1952,7 @@ static int packet_seq_open(struct inode *inode, struct file *file) return seq_open(file, &packet_seq_ops); } -static struct file_operations packet_seq_fops = { +static const struct file_operations packet_seq_fops = { .owner = THIS_MODULE, .open = packet_seq_open, .read = seq_read, diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 7a81a8ee854..8c34f1ca6c8 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -1440,7 +1440,7 @@ static int rose_info_open(struct inode *inode, struct file *file) return seq_open(file, &rose_info_seqops); } -static struct file_operations rose_info_fops = { +static const struct file_operations rose_info_fops = { .owner = THIS_MODULE, .open = rose_info_open, .read = seq_read, diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c index 0dcca4289ee..1ddf7f5fa6d 100644 --- a/net/rose/rose_route.c +++ b/net/rose/rose_route.c @@ -1129,7 +1129,7 @@ static int rose_nodes_open(struct inode *inode, struct file *file) return seq_open(file, &rose_node_seqops); } -struct file_operations rose_nodes_fops = { +const struct file_operations rose_nodes_fops = { .owner = THIS_MODULE, .open = rose_nodes_open, .read = seq_read, @@ -1211,7 +1211,7 @@ static int rose_neigh_open(struct inode *inode, struct file *file) return seq_open(file, &rose_neigh_seqops); } -struct file_operations rose_neigh_fops = { +const struct file_operations rose_neigh_fops = { .owner = THIS_MODULE, .open = rose_neigh_open, .read = seq_read, @@ -1295,7 +1295,7 @@ static int rose_route_open(struct inode *inode, struct file *file) return seq_open(file, &rose_route_seqops); } -struct file_operations rose_routes_fops = { +const struct file_operations rose_routes_fops = { .owner = THIS_MODULE, .open = rose_route_open, .read = seq_read, diff --git a/net/rxrpc/proc.c b/net/rxrpc/proc.c index 29975d99d86..8551c879e45 100644 --- a/net/rxrpc/proc.c +++ b/net/rxrpc/proc.c @@ -37,7 +37,7 @@ static struct seq_operations rxrpc_proc_transports_ops = { .show = rxrpc_proc_transports_show, }; -static struct file_operations rxrpc_proc_transports_fops = { +static const struct file_operations rxrpc_proc_transports_fops = { .open = rxrpc_proc_transports_open, .read = seq_read, .llseek = seq_lseek, @@ -57,7 +57,7 @@ static struct seq_operations rxrpc_proc_peers_ops = { .show = rxrpc_proc_peers_show, }; -static struct file_operations rxrpc_proc_peers_fops = { +static const struct file_operations rxrpc_proc_peers_fops = { .open = rxrpc_proc_peers_open, .read = seq_read, .llseek = seq_lseek, @@ -77,7 +77,7 @@ static struct seq_operations rxrpc_proc_conns_ops = { .show = rxrpc_proc_conns_show, }; -static struct file_operations rxrpc_proc_conns_fops = { +static const struct file_operations rxrpc_proc_conns_fops = { .open = rxrpc_proc_conns_open, .read = seq_read, .llseek = seq_lseek, @@ -97,7 +97,7 @@ static struct seq_operations rxrpc_proc_calls_ops = { .show = rxrpc_proc_calls_show, }; -static struct file_operations rxrpc_proc_calls_fops = { +static const struct file_operations rxrpc_proc_calls_fops = { .open = rxrpc_proc_calls_open, .read = seq_read, .llseek = seq_lseek, diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 60b92fcdc8b..4158127bc20 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1194,7 +1194,7 @@ static int psched_open(struct inode *inode, struct file *file) return single_open(file, psched_show, PDE(inode)->data); } -static struct file_operations psched_fops = { +static const struct file_operations psched_fops = { .owner = THIS_MODULE, .open = psched_open, .read = seq_read, diff --git a/net/sctp/proc.c b/net/sctp/proc.c index e93fc1cc430..2f12bf2d8d3 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c @@ -114,7 +114,7 @@ static int sctp_snmp_seq_open(struct inode *inode, struct file *file) return single_open(file, sctp_snmp_seq_show, NULL); } -static struct file_operations sctp_snmp_seq_fops = { +static const struct file_operations sctp_snmp_seq_fops = { .owner = THIS_MODULE, .open = sctp_snmp_seq_open, .read = seq_read, @@ -264,7 +264,7 @@ static int sctp_eps_seq_open(struct inode *inode, struct file *file) return seq_open(file, &sctp_eps_ops); } -static struct file_operations sctp_eps_seq_fops = { +static const struct file_operations sctp_eps_seq_fops = { .open = sctp_eps_seq_open, .read = seq_read, .llseek = seq_lseek, @@ -374,7 +374,7 @@ static int sctp_assocs_seq_open(struct inode *inode, struct file *file) return seq_open(file, &sctp_assoc_ops); } -static struct file_operations sctp_assocs_seq_fops = { +static const struct file_operations sctp_assocs_seq_fops = { .open = sctp_assocs_seq_open, .read = seq_read, .llseek = seq_lseek, diff --git a/net/socket.c b/net/socket.c index a92f5958023..0778c544241 100644 --- a/net/socket.c +++ b/net/socket.c @@ -117,7 +117,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page, * in the operation structures but are done directly via the socketcall() multiplexor. */ -static struct file_operations socket_file_ops = { +static const struct file_operations socket_file_ops = { .owner = THIS_MODULE, .llseek = no_llseek, .aio_read = sock_aio_read, diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index c80df455802..8612044b918 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -282,9 +282,9 @@ static DEFINE_SPINLOCK(cache_list_lock); static struct cache_detail *current_detail; static int current_index; -static struct file_operations cache_file_operations; -static struct file_operations content_file_operations; -static struct file_operations cache_flush_operations; +static const struct file_operations cache_file_operations; +static const struct file_operations content_file_operations; +static const struct file_operations cache_flush_operations; static void do_cache_clean(struct work_struct *work); static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean); @@ -887,7 +887,7 @@ cache_release(struct inode *inode, struct file *filp) -static struct file_operations cache_file_operations = { +static const struct file_operations cache_file_operations = { .owner = THIS_MODULE, .llseek = no_llseek, .read = cache_read, @@ -1245,7 +1245,7 @@ static int content_release(struct inode *inode, struct file *file) return seq_release(inode, file); } -static struct file_operations content_file_operations = { +static const struct file_operations content_file_operations = { .open = content_open, .read = seq_read, .llseek = seq_lseek, @@ -1297,7 +1297,7 @@ static ssize_t write_flush(struct file * file, const char __user * buf, return count; } -static struct file_operations cache_flush_operations = { +static const struct file_operations cache_flush_operations = { .open = nonseekable_open, .read = read_flush, .write = write_flush, diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 89273d35e0c..e1fad77a225 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -309,7 +309,7 @@ rpc_pipe_ioctl(struct inode *ino, struct file *filp, } } -static struct file_operations rpc_pipe_fops = { +static const struct file_operations rpc_pipe_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .read = rpc_pipe_read, @@ -366,7 +366,7 @@ rpc_info_release(struct inode *inode, struct file *file) return single_release(inode, file); } -static struct file_operations rpc_info_operations = { +static const struct file_operations rpc_info_operations = { .owner = THIS_MODULE, .open = rpc_info_open, .read = seq_read, diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index bd98124c3a6..044d9484bb8 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c @@ -66,7 +66,7 @@ static int rpc_proc_open(struct inode *inode, struct file *file) return single_open(file, rpc_proc_show, PDE(inode)->data); } -static struct file_operations rpc_proc_fops = { +static const struct file_operations rpc_proc_fops = { .owner = THIS_MODULE, .open = rpc_proc_open, .read = seq_read, diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index ac9478d0ca8..606971645b3 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2040,7 +2040,7 @@ out_kfree: goto out; } -static struct file_operations unix_seq_fops = { +static const struct file_operations unix_seq_fops = { .owner = THIS_MODULE, .open = unix_seq_open, .read = seq_read, diff --git a/net/wanrouter/wanproc.c b/net/wanrouter/wanproc.c index abce8287360..205106521ec 100644 --- a/net/wanrouter/wanproc.c +++ b/net/wanrouter/wanproc.c @@ -188,7 +188,7 @@ static int status_open(struct inode *inode, struct file *file) return seq_open(file, &status_op); } -static struct file_operations config_fops = { +static const struct file_operations config_fops = { .owner = THIS_MODULE, .open = config_open, .read = seq_read, @@ -196,7 +196,7 @@ static struct file_operations config_fops = { .release = seq_release, }; -static struct file_operations status_fops = { +static const struct file_operations status_fops = { .owner = THIS_MODULE, .open = status_open, .read = seq_read, @@ -271,7 +271,7 @@ static int wandev_open(struct inode *inode, struct file *file) return single_open(file, wandev_show, PDE(inode)->data); } -static struct file_operations wandev_fops = { +static const struct file_operations wandev_fops = { .owner = THIS_MODULE, .open = wandev_open, .read = seq_read, diff --git a/net/x25/x25_proc.c b/net/x25/x25_proc.c index 3c9f1ba5622..96001f0c64f 100644 --- a/net/x25/x25_proc.c +++ b/net/x25/x25_proc.c @@ -270,7 +270,7 @@ static int x25_seq_forward_open(struct inode *inode, struct file *file) return seq_open(file, &x25_seq_forward_ops); } -static struct file_operations x25_seq_socket_fops = { +static const struct file_operations x25_seq_socket_fops = { .owner = THIS_MODULE, .open = x25_seq_socket_open, .read = seq_read, @@ -278,7 +278,7 @@ static struct file_operations x25_seq_socket_fops = { .release = seq_release, }; -static struct file_operations x25_seq_route_fops = { +static const struct file_operations x25_seq_route_fops = { .owner = THIS_MODULE, .open = x25_seq_route_open, .read = seq_read, -- cgit v1.2.3-70-g09d2