aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-09-17 23:53:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-17 23:53:52 -0400
commitf205ce83a766c08965ec78342f138cdc00631fba (patch)
tree7a9d2db6c16594ef7c730ca93a87131cf0abca41 /net
parent3dc95666df0e1ae5b7381a8ec97a583bb3ce4306 (diff)
parentb31c50a7f9e93a61d14740dedcbbf2c376998bc7 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (66 commits) be2net: fix some cmds to use mccq instead of mbox atl1e: fix 2.6.31-git4 -- ATL1E 0000:03:00.0: DMA-API: device driver frees DMA pkt_sched: Fix qstats.qlen updating in dump_stats ipv6: Log the affected address when DAD failure occurs wl12xx: Fix print_mac() conversion. af_iucv: fix race when queueing skbs on the backlog queue af_iucv: do not call iucv_sock_kill() twice af_iucv: handle non-accepted sockets after resuming from suspend af_iucv: fix race in __iucv_sock_wait() iucv: use correct output register in iucv_query_maxconn() iucv: fix iucv_buffer_cpumask check when calling IUCV functions iucv: suspend/resume error msg for left over pathes wl12xx: switch to %pM to print the mac address b44: the poll handler b44_poll must not enable IRQ unconditionally ipv6: Ignore route option with ROUTER_PREF_INVALID bonding: make ab_arp select active slaves as other modes cfg80211: fix SME connect rc80211_minstrel: fix contention window calculation ssb/sdio: fix printk format warnings p54usb: add Zcomax XG-705A usbid ...
Diffstat (limited to 'net')
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/can/af_can.c4
-rw-r--r--net/core/dev.c4
-rw-r--r--net/dccp/ccids/Kconfig6
-rw-r--r--net/dccp/ccids/ccid2.c2
-rw-r--r--net/dccp/ccids/ccid2.h8
-rw-r--r--net/dccp/ccids/ccid3.c5
-rw-r--r--net/dccp/ccids/ccid3.h50
-rw-r--r--net/dccp/ccids/lib/loss_interval.c7
-rw-r--r--net/dccp/ccids/lib/loss_interval.h2
-rw-r--r--net/dccp/ccids/lib/packet_history.c4
-rw-r--r--net/dccp/ccids/lib/packet_history.h1
-rw-r--r--net/dccp/ccids/lib/tfrc.h4
-rw-r--r--net/dccp/ccids/lib/tfrc_equation.c26
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/dccp/ipv6.c4
-rw-r--r--net/ieee802154/dgram.c2
-rw-r--r--net/ieee802154/netlink.c4
-rw-r--r--net/ieee802154/raw.c2
-rw-r--r--net/ipv4/af_inet.c18
-rw-r--r--net/ipv4/ah4.c2
-rw-r--r--net/ipv4/devinet.c6
-rw-r--r--net/ipv4/esp4.c2
-rw-r--r--net/ipv4/icmp.c2
-rw-r--r--net/ipv4/igmp.c22
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_input.c2
-rw-r--r--net/ipv4/ipcomp.c2
-rw-r--r--net/ipv4/ipmr.c6
-rw-r--r--net/ipv4/protocol.c6
-rw-r--r--net/ipv4/tcp.c2
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/ipv4/tcp_minisocks.c4
-rw-r--r--net/ipv4/tunnel4.c4
-rw-r--r--net/ipv4/udplite.c2
-rw-r--r--net/ipv6/addrconf.c23
-rw-r--r--net/ipv6/af_inet6.c10
-rw-r--r--net/ipv6/ah6.c2
-rw-r--r--net/ipv6/esp6.c2
-rw-r--r--net/ipv6/exthdrs.c6
-rw-r--r--net/ipv6/icmp.c4
-rw-r--r--net/ipv6/ip6_input.c2
-rw-r--r--net/ipv6/ip6mr.c6
-rw-r--r--net/ipv6/ipcomp6.c2
-rw-r--r--net/ipv6/mcast.c19
-rw-r--r--net/ipv6/protocol.c6
-rw-r--r--net/ipv6/reassembly.c2
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/ipv6/tcp_ipv6.c7
-rw-r--r--net/ipv6/tunnel6.c4
-rw-r--r--net/ipv6/udp.c2
-rw-r--r--net/ipv6/udplite.c2
-rw-r--r--net/iucv/af_iucv.c33
-rw-r--r--net/iucv/iucv.c38
-rw-r--r--net/mac80211/rc80211_minstrel.c2
-rw-r--r--net/netlink/af_netlink.c51
-rw-r--r--net/netlink/genetlink.c5
-rw-r--r--net/phonet/pn_dev.c9
-rw-r--r--net/rds/af_rds.c2
-rw-r--r--net/rose/af_rose.c4
-rw-r--r--net/rxrpc/ar-ack.c6
-rw-r--r--net/rxrpc/ar-internal.h32
-rw-r--r--net/rxrpc/ar-key.c914
-rw-r--r--net/rxrpc/ar-security.c8
-rw-r--r--net/rxrpc/rxkad.c47
-rw-r--r--net/sched/sch_api.c29
-rw-r--r--net/sched/sch_drr.c4
-rw-r--r--net/sched/sch_mq.c14
-rw-r--r--net/sched/sch_multiq.c1
-rw-r--r--net/sched/sch_prio.c1
-rw-r--r--net/sctp/ipv6.c2
-rw-r--r--net/sctp/protocol.c2
-rw-r--r--net/socket.c1
-rw-r--r--net/wireless/scan.c7
-rw-r--r--net/wireless/sme.c21
76 files changed, 1255 insertions, 306 deletions
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 4a6ff2ba4d07..b1a4290996b5 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1372,7 +1372,7 @@ static int atalk_route_packet(struct sk_buff *skb, struct net_device *dev,
1372 1372
1373 if (aarp_send_ddp(rt->dev, skb, &ta, NULL) == NET_XMIT_DROP) 1373 if (aarp_send_ddp(rt->dev, skb, &ta, NULL) == NET_XMIT_DROP)
1374 return NET_RX_DROP; 1374 return NET_RX_DROP;
1375 return NET_XMIT_SUCCESS; 1375 return NET_RX_SUCCESS;
1376free_it: 1376free_it:
1377 kfree_skb(skb); 1377 kfree_skb(skb);
1378drop: 1378drop:
diff --git a/net/can/af_can.c b/net/can/af_can.c
index ef1c43a2ed56..606832115674 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -199,6 +199,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
199 * @skb: pointer to socket buffer with CAN frame in data section 199 * @skb: pointer to socket buffer with CAN frame in data section
200 * @loop: loopback for listeners on local CAN sockets (recommended default!) 200 * @loop: loopback for listeners on local CAN sockets (recommended default!)
201 * 201 *
202 * Due to the loopback this routine must not be called from hardirq context.
203 *
202 * Return: 204 * Return:
203 * 0 on success 205 * 0 on success
204 * -ENETDOWN when the selected interface is down 206 * -ENETDOWN when the selected interface is down
@@ -278,7 +280,7 @@ int can_send(struct sk_buff *skb, int loop)
278 } 280 }
279 281
280 if (newskb) 282 if (newskb)
281 netif_rx(newskb); 283 netif_rx_ni(newskb);
282 284
283 /* update statistics */ 285 /* update statistics */
284 can_stats.tx_frames++; 286 can_stats.tx_frames++;
diff --git a/net/core/dev.c b/net/core/dev.c
index 84945470ab38..560c8c9c03ab 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1017,9 +1017,9 @@ void netdev_state_change(struct net_device *dev)
1017} 1017}
1018EXPORT_SYMBOL(netdev_state_change); 1018EXPORT_SYMBOL(netdev_state_change);
1019 1019
1020void netdev_bonding_change(struct net_device *dev) 1020void netdev_bonding_change(struct net_device *dev, unsigned long event)
1021{ 1021{
1022 call_netdevice_notifiers(NETDEV_BONDING_FAILOVER, dev); 1022 call_netdevice_notifiers(event, dev);
1023} 1023}
1024EXPORT_SYMBOL(netdev_bonding_change); 1024EXPORT_SYMBOL(netdev_bonding_change);
1025 1025
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig
index 4b5db44970aa..8408398cd44e 100644
--- a/net/dccp/ccids/Kconfig
+++ b/net/dccp/ccids/Kconfig
@@ -66,9 +66,9 @@ config IP_DCCP_CCID3_RTO
66 A value of 0 disables this feature by enforcing the value specified 66 A value of 0 disables this feature by enforcing the value specified
67 in RFC 3448. The following values have been suggested as bounds for 67 in RFC 3448. The following values have been suggested as bounds for
68 experimental use: 68 experimental use:
69 * 16-20ms to match the typical multimedia inter-frame interval 69 * 16-20ms to match the typical multimedia inter-frame interval
70 * 100ms as a reasonable compromise [default] 70 * 100ms as a reasonable compromise [default]
71 * 1000ms corresponds to the lower TCP RTO bound (RFC 2988, 2.4) 71 * 1000ms corresponds to the lower TCP RTO bound (RFC 2988, 2.4)
72 72
73 The default of 100ms is a compromise between a large value for 73 The default of 100ms is a compromise between a large value for
74 efficient DCCP implementations, and a small value to avoid disrupting 74 efficient DCCP implementations, and a small value to avoid disrupting
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index d235294ace23..e8cf99e880b0 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid2.c
3 *
4 * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk> 2 * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
5 * 3 *
6 * Changes to meet Linux coding standards, and DCCP infrastructure fixes. 4 * Changes to meet Linux coding standards, and DCCP infrastructure fixes.
diff --git a/net/dccp/ccids/ccid2.h b/net/dccp/ccids/ccid2.h
index 2c94ca029010..326ac90fb909 100644
--- a/net/dccp/ccids/ccid2.h
+++ b/net/dccp/ccids/ccid2.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid2.h
3 *
4 * Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk> 2 * Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk>
5 * 3 *
6 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -40,14 +38,14 @@ struct ccid2_seq {
40#define CCID2_SEQBUF_LEN 1024 38#define CCID2_SEQBUF_LEN 1024
41#define CCID2_SEQBUF_MAX 128 39#define CCID2_SEQBUF_MAX 128
42 40
43/** struct ccid2_hc_tx_sock - CCID2 TX half connection 41/**
44 * 42 * struct ccid2_hc_tx_sock - CCID2 TX half connection
45 * @ccid2hctx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5 43 * @ccid2hctx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5
46 * @ccid2hctx_packets_acked - Ack counter for deriving cwnd growth (RFC 3465) 44 * @ccid2hctx_packets_acked - Ack counter for deriving cwnd growth (RFC 3465)
47 * @ccid2hctx_lastrtt -time RTT was last measured 45 * @ccid2hctx_lastrtt -time RTT was last measured
48 * @ccid2hctx_rpseq - last consecutive seqno 46 * @ccid2hctx_rpseq - last consecutive seqno
49 * @ccid2hctx_rpdupack - dupacks since rpseq 47 * @ccid2hctx_rpdupack - dupacks since rpseq
50*/ 48 */
51struct ccid2_hc_tx_sock { 49struct ccid2_hc_tx_sock {
52 u32 ccid2hctx_cwnd; 50 u32 ccid2hctx_cwnd;
53 u32 ccid2hctx_ssthresh; 51 u32 ccid2hctx_ssthresh;
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index f596ce149c3c..34dcc798c457 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid3.c
3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
6 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> 4 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
@@ -750,7 +748,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
750 return 0; 748 return 0;
751} 749}
752 750
753/** ccid3_first_li - Implements [RFC 3448, 6.3.1] 751/**
752 * ccid3_first_li - Implements [RFC 5348, 6.3.1]
754 * 753 *
755 * Determine the length of the first loss interval via inverse lookup. 754 * Determine the length of the first loss interval via inverse lookup.
756 * Assume that X_recv can be computed by the throughput equation 755 * Assume that X_recv can be computed by the throughput equation
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 49ca32bd7e79..e5a244143846 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/ccid3.h
3 *
4 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 2 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
5 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 3 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
6 * 4 *
@@ -75,8 +73,8 @@ enum ccid3_hc_tx_states {
75 TFRC_SSTATE_TERM, 73 TFRC_SSTATE_TERM,
76}; 74};
77 75
78/** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket 76/**
79 * 77 * struct ccid3_hc_tx_sock - CCID3 sender half-connection socket
80 * @ccid3hctx_x - Current sending rate in 64 * bytes per second 78 * @ccid3hctx_x - Current sending rate in 64 * bytes per second
81 * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second 79 * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second
82 * @ccid3hctx_x_calc - Calculated rate in bytes per second 80 * @ccid3hctx_x_calc - Calculated rate in bytes per second
@@ -119,9 +117,9 @@ struct ccid3_hc_tx_sock {
119 117
120static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) 118static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
121{ 119{
122 struct ccid3_hc_tx_sock *hctx = ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid); 120 struct ccid3_hc_tx_sock *hctx = ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid);
123 BUG_ON(hctx == NULL); 121 BUG_ON(hctx == NULL);
124 return hctx; 122 return hctx;
125} 123}
126 124
127/* TFRC receiver states */ 125/* TFRC receiver states */
@@ -131,22 +129,22 @@ enum ccid3_hc_rx_states {
131 TFRC_RSTATE_TERM = 127, 129 TFRC_RSTATE_TERM = 127,
132}; 130};
133 131
134/** struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket 132/**
135 * 133 * struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket
136 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3) 134 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3)
137 * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard) 135 * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard)
138 * @ccid3hcrx_p - Current loss event rate (RFC 3448 5.4) 136 * @ccid3hcrx_p - Current loss event rate (RFC 3448 5.4)
139 * @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1) 137 * @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1)
140 * @ccid3hcrx_state - Receiver state, one of %ccid3_hc_rx_states 138 * @ccid3hcrx_state - Receiver state, one of %ccid3_hc_rx_states
141 * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes 139 * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes
142 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3) 140 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3)
143 * @ccid3hcrx_rtt - Receiver estimate of RTT 141 * @ccid3hcrx_rtt - Receiver estimate of RTT
144 * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent 142 * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent
145 * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent 143 * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent
146 * @ccid3hcrx_hist - Packet history (loss detection + RTT sampling) 144 * @ccid3hcrx_hist - Packet history (loss detection + RTT sampling)
147 * @ccid3hcrx_li_hist - Loss Interval database 145 * @ccid3hcrx_li_hist - Loss Interval database
148 * @ccid3hcrx_s - Received packet size in bytes 146 * @ccid3hcrx_s - Received packet size in bytes
149 * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5) 147 * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5)
150 */ 148 */
151struct ccid3_hc_rx_sock { 149struct ccid3_hc_rx_sock {
152 u8 ccid3hcrx_last_counter:4; 150 u8 ccid3hcrx_last_counter:4;
@@ -163,9 +161,9 @@ struct ccid3_hc_rx_sock {
163 161
164static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) 162static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk)
165{ 163{
166 struct ccid3_hc_rx_sock *hcrx = ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid); 164 struct ccid3_hc_rx_sock *hcrx = ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid);
167 BUG_ON(hcrx == NULL); 165 BUG_ON(hcrx == NULL);
168 return hcrx; 166 return hcrx;
169} 167}
170 168
171#endif /* _DCCP_CCID3_H_ */ 169#endif /* _DCCP_CCID3_H_ */
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c
index 4d1e40127264..8fc3cbf79071 100644
--- a/net/dccp/ccids/lib/loss_interval.c
+++ b/net/dccp/ccids/lib/loss_interval.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/lib/loss_interval.c
3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
6 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> 4 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
@@ -21,7 +19,7 @@ static const int tfrc_lh_weights[NINTERVAL] = { 10, 10, 10, 10, 8, 6, 4, 2 };
21/* implements LIFO semantics on the array */ 19/* implements LIFO semantics on the array */
22static inline u8 LIH_INDEX(const u8 ctr) 20static inline u8 LIH_INDEX(const u8 ctr)
23{ 21{
24 return (LIH_SIZE - 1 - (ctr % LIH_SIZE)); 22 return LIH_SIZE - 1 - (ctr % LIH_SIZE);
25} 23}
26 24
27/* the `counter' index always points at the next entry to be populated */ 25/* the `counter' index always points at the next entry to be populated */
@@ -129,7 +127,8 @@ static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur,
129 (cur->li_is_closed || SUB16(new_loss->tfrchrx_ccval, cur->li_ccval) > 4); 127 (cur->li_is_closed || SUB16(new_loss->tfrchrx_ccval, cur->li_ccval) > 4);
130} 128}
131 129
132/** tfrc_lh_interval_add - Insert new record into the Loss Interval database 130/**
131 * tfrc_lh_interval_add - Insert new record into the Loss Interval database
133 * @lh: Loss Interval database 132 * @lh: Loss Interval database
134 * @rh: Receive history containing a fresh loss event 133 * @rh: Receive history containing a fresh loss event
135 * @calc_first_li: Caller-dependent routine to compute length of first interval 134 * @calc_first_li: Caller-dependent routine to compute length of first interval
diff --git a/net/dccp/ccids/lib/loss_interval.h b/net/dccp/ccids/lib/loss_interval.h
index 246018a3b269..d1d2f5383b7d 100644
--- a/net/dccp/ccids/lib/loss_interval.h
+++ b/net/dccp/ccids/lib/loss_interval.h
@@ -1,8 +1,6 @@
1#ifndef _DCCP_LI_HIST_ 1#ifndef _DCCP_LI_HIST_
2#define _DCCP_LI_HIST_ 2#define _DCCP_LI_HIST_
3/* 3/*
4 * net/dccp/ccids/lib/loss_interval.h
5 *
6 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
7 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
8 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> 6 * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c
index b7785b3581ec..3a4f414e94a0 100644
--- a/net/dccp/ccids/lib/packet_history.c
+++ b/net/dccp/ccids/lib/packet_history.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/packet_history.c
3 *
4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 2 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
5 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. 3 * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
6 * 4 *
@@ -128,7 +126,7 @@ u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head, const u64 seqno,
128 126
129 127
130/* 128/*
131 * Receiver History Routines 129 * Receiver History Routines
132 */ 130 */
133static struct kmem_cache *tfrc_rx_hist_slab; 131static struct kmem_cache *tfrc_rx_hist_slab;
134 132
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index 461cc91cce88..7df6c5299999 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -70,7 +70,6 @@ struct tfrc_rx_hist_entry {
70 70
71/** 71/**
72 * tfrc_rx_hist - RX history structure for TFRC-based protocols 72 * tfrc_rx_hist - RX history structure for TFRC-based protocols
73 *
74 * @ring: Packet history for RTT sampling and loss detection 73 * @ring: Packet history for RTT sampling and loss detection
75 * @loss_count: Number of entries in circular history 74 * @loss_count: Number of entries in circular history
76 * @loss_start: Movable index (for loss detection) 75 * @loss_start: Movable index (for loss detection)
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h
index e9720b143275..01bb48e96c2e 100644
--- a/net/dccp/ccids/lib/tfrc.h
+++ b/net/dccp/ccids/lib/tfrc.h
@@ -1,8 +1,6 @@
1#ifndef _TFRC_H_ 1#ifndef _TFRC_H_
2#define _TFRC_H_ 2#define _TFRC_H_
3/* 3/*
4 * net/dccp/ccids/lib/tfrc.h
5 *
6 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK 4 * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
7 * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. 5 * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand.
8 * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz> 6 * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz>
@@ -32,7 +30,7 @@ extern int tfrc_debug;
32/* integer-arithmetic divisions of type (a * 1000000)/b */ 30/* integer-arithmetic divisions of type (a * 1000000)/b */
33static inline u64 scaled_div(u64 a, u64 b) 31static inline u64 scaled_div(u64 a, u64 b)
34{ 32{
35 BUG_ON(b==0); 33 BUG_ON(b == 0);
36 return div64_u64(a * 1000000, b); 34 return div64_u64(a * 1000000, b);
37} 35}
38 36
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c
index c5d3a9e5a5a4..22ca1cf0eb55 100644
--- a/net/dccp/ccids/lib/tfrc_equation.c
+++ b/net/dccp/ccids/lib/tfrc_equation.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * net/dccp/ccids/lib/tfrc_equation.c
3 *
4 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. 2 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
5 * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz> 3 * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz>
6 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> 4 * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
@@ -79,10 +77,10 @@
79 } 77 }
80 78
81 With the given configuration, we have, with M = TFRC_CALC_X_ARRSIZE-1, 79 With the given configuration, we have, with M = TFRC_CALC_X_ARRSIZE-1,
82 lookup[0][0] = g(1000000/(M+1)) = 1000000 * f(0.2%) 80 lookup[0][0] = g(1000000/(M+1)) = 1000000 * f(0.2%)
83 lookup[M][0] = g(1000000) = 1000000 * f(100%) 81 lookup[M][0] = g(1000000) = 1000000 * f(100%)
84 lookup[0][1] = g(TFRC_SMALLEST_P) = 1000000 * f(0.01%) 82 lookup[0][1] = g(TFRC_SMALLEST_P) = 1000000 * f(0.01%)
85 lookup[M][1] = g(TFRC_CALC_X_SPLIT) = 1000000 * f(5%) 83 lookup[M][1] = g(TFRC_CALC_X_SPLIT) = 1000000 * f(5%)
86 84
87 In summary, the two columns represent f(p) for the following ranges: 85 In summary, the two columns represent f(p) for the following ranges:
88 * The first column is for 0.002 <= p <= 1.0 86 * The first column is for 0.002 <= p <= 1.0
@@ -610,11 +608,10 @@ static inline u32 tfrc_binsearch(u32 fval, u8 small)
610 608
611/** 609/**
612 * tfrc_calc_x - Calculate the send rate as per section 3.1 of RFC3448 610 * tfrc_calc_x - Calculate the send rate as per section 3.1 of RFC3448
613 * 611 * @s: packet size in bytes
614 * @s: packet size in bytes 612 * @R: RTT scaled by 1000000 (i.e., microseconds)
615 * @R: RTT scaled by 1000000 (i.e., microseconds) 613 * @p: loss ratio estimate scaled by 1000000
616 * @p: loss ratio estimate scaled by 1000000 614 * Returns X_calc in bytes per second (not scaled).
617 * Returns X_calc in bytes per second (not scaled).
618 */ 615 */
619u32 tfrc_calc_x(u16 s, u32 R, u32 p) 616u32 tfrc_calc_x(u16 s, u32 R, u32 p)
620{ 617{
@@ -630,17 +627,17 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
630 return ~0U; 627 return ~0U;
631 } 628 }
632 629
633 if (p <= TFRC_CALC_X_SPLIT) { /* 0.0000 < p <= 0.05 */ 630 if (p <= TFRC_CALC_X_SPLIT) { /* 0.0000 < p <= 0.05 */
634 if (p < TFRC_SMALLEST_P) { /* 0.0000 < p < 0.0001 */ 631 if (p < TFRC_SMALLEST_P) { /* 0.0000 < p < 0.0001 */
635 DCCP_WARN("Value of p (%d) below resolution. " 632 DCCP_WARN("Value of p (%d) below resolution. "
636 "Substituting %d\n", p, TFRC_SMALLEST_P); 633 "Substituting %d\n", p, TFRC_SMALLEST_P);
637 index = 0; 634 index = 0;
638 } else /* 0.0001 <= p <= 0.05 */ 635 } else /* 0.0001 <= p <= 0.05 */
639 index = p/TFRC_SMALLEST_P - 1; 636 index = p/TFRC_SMALLEST_P - 1;
640 637
641 f = tfrc_calc_x_lookup[index][1]; 638 f = tfrc_calc_x_lookup[index][1];
642 639
643 } else { /* 0.05 < p <= 1.00 */ 640 } else { /* 0.05 < p <= 1.00 */
644 index = p/(1000000/TFRC_CALC_X_ARRSIZE) - 1; 641 index = p/(1000000/TFRC_CALC_X_ARRSIZE) - 1;
645 642
646 f = tfrc_calc_x_lookup[index][0]; 643 f = tfrc_calc_x_lookup[index][0];
@@ -661,7 +658,6 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
661 658
662/** 659/**
663 * tfrc_calc_x_reverse_lookup - try to find p given f(p) 660 * tfrc_calc_x_reverse_lookup - try to find p given f(p)
664 *
665 * @fvalue: function value to match, scaled by 1000000 661 * @fvalue: function value to match, scaled by 1000000
666 * Returns closest match for p, also scaled by 1000000 662 * Returns closest match for p, also scaled by 1000000
667 */ 663 */
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index d01c00de1ad0..7302e1498d46 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -948,7 +948,7 @@ static struct proto dccp_v4_prot = {
948#endif 948#endif
949}; 949};
950 950
951static struct net_protocol dccp_v4_protocol = { 951static const struct net_protocol dccp_v4_protocol = {
952 .handler = dccp_v4_rcv, 952 .handler = dccp_v4_rcv,
953 .err_handler = dccp_v4_err, 953 .err_handler = dccp_v4_err,
954 .no_policy = 1, 954 .no_policy = 1,
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 64f011cc4491..e48ca5d45658 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -1152,13 +1152,13 @@ static struct proto dccp_v6_prot = {
1152#endif 1152#endif
1153}; 1153};
1154 1154
1155static struct inet6_protocol dccp_v6_protocol = { 1155static const struct inet6_protocol dccp_v6_protocol = {
1156 .handler = dccp_v6_rcv, 1156 .handler = dccp_v6_rcv,
1157 .err_handler = dccp_v6_err, 1157 .err_handler = dccp_v6_err,
1158 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, 1158 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
1159}; 1159};
1160 1160
1161static struct proto_ops inet6_dccp_ops = { 1161static const struct proto_ops inet6_dccp_ops = {
1162 .family = PF_INET6, 1162 .family = PF_INET6,
1163 .owner = THIS_MODULE, 1163 .owner = THIS_MODULE,
1164 .release = inet6_release, 1164 .release = inet6_release,
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 77ae6852b93d..51593a48f2dd 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -414,7 +414,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname,
414} 414}
415 415
416static int dgram_setsockopt(struct sock *sk, int level, int optname, 416static int dgram_setsockopt(struct sock *sk, int level, int optname,
417 char __user *optval, int __user optlen) 417 char __user *optval, int optlen)
418{ 418{
419 struct dgram_sock *ro = dgram_sk(sk); 419 struct dgram_sock *ro = dgram_sk(sk);
420 int val; 420 int val;
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c
index 2106ecbf0308..ca767bde17a4 100644
--- a/net/ieee802154/netlink.c
+++ b/net/ieee802154/netlink.c
@@ -35,6 +35,7 @@
35#include <net/ieee802154_netdev.h> 35#include <net/ieee802154_netdev.h>
36 36
37static unsigned int ieee802154_seq_num; 37static unsigned int ieee802154_seq_num;
38static DEFINE_SPINLOCK(ieee802154_seq_lock);
38 39
39static struct genl_family ieee802154_coordinator_family = { 40static struct genl_family ieee802154_coordinator_family = {
40 .id = GENL_ID_GENERATE, 41 .id = GENL_ID_GENERATE,
@@ -57,12 +58,15 @@ static struct sk_buff *ieee802154_nl_create(int flags, u8 req)
57{ 58{
58 void *hdr; 59 void *hdr;
59 struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 60 struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
61 unsigned long f;
60 62
61 if (!msg) 63 if (!msg)
62 return NULL; 64 return NULL;
63 65
66 spin_lock_irqsave(&ieee802154_seq_lock, f);
64 hdr = genlmsg_put(msg, 0, ieee802154_seq_num++, 67 hdr = genlmsg_put(msg, 0, ieee802154_seq_num++,
65 &ieee802154_coordinator_family, flags, req); 68 &ieee802154_coordinator_family, flags, req);
69 spin_unlock_irqrestore(&ieee802154_seq_lock, f);
66 if (!hdr) { 70 if (!hdr) {
67 nlmsg_free(msg); 71 nlmsg_free(msg);
68 return NULL; 72 return NULL;
diff --git a/net/ieee802154/raw.c b/net/ieee802154/raw.c
index 4681501aae93..13198859982e 100644
--- a/net/ieee802154/raw.c
+++ b/net/ieee802154/raw.c
@@ -244,7 +244,7 @@ static int raw_getsockopt(struct sock *sk, int level, int optname,
244} 244}
245 245
246static int raw_setsockopt(struct sock *sk, int level, int optname, 246static int raw_setsockopt(struct sock *sk, int level, int optname,
247 char __user *optval, int __user optlen) 247 char __user *optval, int optlen)
248{ 248{
249 return -EOPNOTSUPP; 249 return -EOPNOTSUPP;
250} 250}
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 6c30a73f03f5..58c4b0f7c4aa 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(build_ehash_secret);
244static inline int inet_netns_ok(struct net *net, int protocol) 244static inline int inet_netns_ok(struct net *net, int protocol)
245{ 245{
246 int hash; 246 int hash;
247 struct net_protocol *ipprot; 247 const struct net_protocol *ipprot;
248 248
249 if (net_eq(net, &init_net)) 249 if (net_eq(net, &init_net))
250 return 1; 250 return 1;
@@ -1162,7 +1162,7 @@ EXPORT_SYMBOL(inet_sk_rebuild_header);
1162static int inet_gso_send_check(struct sk_buff *skb) 1162static int inet_gso_send_check(struct sk_buff *skb)
1163{ 1163{
1164 struct iphdr *iph; 1164 struct iphdr *iph;
1165 struct net_protocol *ops; 1165 const struct net_protocol *ops;
1166 int proto; 1166 int proto;
1167 int ihl; 1167 int ihl;
1168 int err = -EINVAL; 1168 int err = -EINVAL;
@@ -1198,7 +1198,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features)
1198{ 1198{
1199 struct sk_buff *segs = ERR_PTR(-EINVAL); 1199 struct sk_buff *segs = ERR_PTR(-EINVAL);
1200 struct iphdr *iph; 1200 struct iphdr *iph;
1201 struct net_protocol *ops; 1201 const struct net_protocol *ops;
1202 int proto; 1202 int proto;
1203 int ihl; 1203 int ihl;
1204 int id; 1204 int id;
@@ -1265,7 +1265,7 @@ out:
1265static struct sk_buff **inet_gro_receive(struct sk_buff **head, 1265static struct sk_buff **inet_gro_receive(struct sk_buff **head,
1266 struct sk_buff *skb) 1266 struct sk_buff *skb)
1267{ 1267{
1268 struct net_protocol *ops; 1268 const struct net_protocol *ops;
1269 struct sk_buff **pp = NULL; 1269 struct sk_buff **pp = NULL;
1270 struct sk_buff *p; 1270 struct sk_buff *p;
1271 struct iphdr *iph; 1271 struct iphdr *iph;
@@ -1342,7 +1342,7 @@ out:
1342 1342
1343static int inet_gro_complete(struct sk_buff *skb) 1343static int inet_gro_complete(struct sk_buff *skb)
1344{ 1344{
1345 struct net_protocol *ops; 1345 const struct net_protocol *ops;
1346 struct iphdr *iph = ip_hdr(skb); 1346 struct iphdr *iph = ip_hdr(skb);
1347 int proto = iph->protocol & (MAX_INET_PROTOS - 1); 1347 int proto = iph->protocol & (MAX_INET_PROTOS - 1);
1348 int err = -ENOSYS; 1348 int err = -ENOSYS;
@@ -1427,13 +1427,13 @@ void snmp_mib_free(void *ptr[2])
1427EXPORT_SYMBOL_GPL(snmp_mib_free); 1427EXPORT_SYMBOL_GPL(snmp_mib_free);
1428 1428
1429#ifdef CONFIG_IP_MULTICAST 1429#ifdef CONFIG_IP_MULTICAST
1430static struct net_protocol igmp_protocol = { 1430static const struct net_protocol igmp_protocol = {
1431 .handler = igmp_rcv, 1431 .handler = igmp_rcv,
1432 .netns_ok = 1, 1432 .netns_ok = 1,
1433}; 1433};
1434#endif 1434#endif
1435 1435
1436static struct net_protocol tcp_protocol = { 1436static const struct net_protocol tcp_protocol = {
1437 .handler = tcp_v4_rcv, 1437 .handler = tcp_v4_rcv,
1438 .err_handler = tcp_v4_err, 1438 .err_handler = tcp_v4_err,
1439 .gso_send_check = tcp_v4_gso_send_check, 1439 .gso_send_check = tcp_v4_gso_send_check,
@@ -1444,7 +1444,7 @@ static struct net_protocol tcp_protocol = {
1444 .netns_ok = 1, 1444 .netns_ok = 1,
1445}; 1445};
1446 1446
1447static struct net_protocol udp_protocol = { 1447static const struct net_protocol udp_protocol = {
1448 .handler = udp_rcv, 1448 .handler = udp_rcv,
1449 .err_handler = udp_err, 1449 .err_handler = udp_err,
1450 .gso_send_check = udp4_ufo_send_check, 1450 .gso_send_check = udp4_ufo_send_check,
@@ -1453,7 +1453,7 @@ static struct net_protocol udp_protocol = {
1453 .netns_ok = 1, 1453 .netns_ok = 1,
1454}; 1454};
1455 1455
1456static struct net_protocol icmp_protocol = { 1456static const struct net_protocol icmp_protocol = {
1457 .handler = icmp_rcv, 1457 .handler = icmp_rcv,
1458 .no_policy = 1, 1458 .no_policy = 1,
1459 .netns_ok = 1, 1459 .netns_ok = 1,
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index e878e494296e..5c662703eb1e 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -311,7 +311,7 @@ static const struct xfrm_type ah_type =
311 .output = ah_output 311 .output = ah_output
312}; 312};
313 313
314static struct net_protocol ah4_protocol = { 314static const struct net_protocol ah4_protocol = {
315 .handler = xfrm4_rcv, 315 .handler = xfrm4_rcv,
316 .err_handler = ah4_err, 316 .err_handler = ah4_err,
317 .no_policy = 1, 317 .no_policy = 1,
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 3863c3a4223f..07336c6201f0 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1087,6 +1087,12 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
1087 case NETDEV_DOWN: 1087 case NETDEV_DOWN:
1088 ip_mc_down(in_dev); 1088 ip_mc_down(in_dev);
1089 break; 1089 break;
1090 case NETDEV_BONDING_OLDTYPE:
1091 ip_mc_unmap(in_dev);
1092 break;
1093 case NETDEV_BONDING_NEWTYPE:
1094 ip_mc_remap(in_dev);
1095 break;
1090 case NETDEV_CHANGEMTU: 1096 case NETDEV_CHANGEMTU:
1091 if (inetdev_valid_mtu(dev->mtu)) 1097 if (inetdev_valid_mtu(dev->mtu))
1092 break; 1098 break;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 18bb383ea393..12f7287e902d 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -615,7 +615,7 @@ static const struct xfrm_type esp_type =
615 .output = esp_output 615 .output = esp_output
616}; 616};
617 617
618static struct net_protocol esp4_protocol = { 618static const struct net_protocol esp4_protocol = {
619 .handler = xfrm4_rcv, 619 .handler = xfrm4_rcv,
620 .err_handler = esp4_err, 620 .err_handler = esp4_err,
621 .no_policy = 1, 621 .no_policy = 1,
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 97c410e84388..5bc13fe816d1 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -655,7 +655,7 @@ static void icmp_unreach(struct sk_buff *skb)
655 struct iphdr *iph; 655 struct iphdr *iph;
656 struct icmphdr *icmph; 656 struct icmphdr *icmph;
657 int hash, protocol; 657 int hash, protocol;
658 struct net_protocol *ipprot; 658 const struct net_protocol *ipprot;
659 u32 info = 0; 659 u32 info = 0;
660 struct net *net; 660 struct net *net;
661 661
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 01b4284ed694..d41e5de79a82 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1298,6 +1298,28 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
1298 } 1298 }
1299} 1299}
1300 1300
1301/* Device changing type */
1302
1303void ip_mc_unmap(struct in_device *in_dev)
1304{
1305 struct ip_mc_list *i;
1306
1307 ASSERT_RTNL();
1308
1309 for (i = in_dev->mc_list; i; i = i->next)
1310 igmp_group_dropped(i);
1311}
1312
1313void ip_mc_remap(struct in_device *in_dev)
1314{
1315 struct ip_mc_list *i;
1316
1317 ASSERT_RTNL();
1318
1319 for (i = in_dev->mc_list; i; i = i->next)
1320 igmp_group_added(i);
1321}
1322
1301/* Device going down */ 1323/* Device going down */
1302 1324
1303void ip_mc_down(struct in_device *in_dev) 1325void ip_mc_down(struct in_device *in_dev)
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 533afaadefd4..d9645c94a067 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1288,7 +1288,7 @@ static void ipgre_fb_tunnel_init(struct net_device *dev)
1288} 1288}
1289 1289
1290 1290
1291static struct net_protocol ipgre_protocol = { 1291static const struct net_protocol ipgre_protocol = {
1292 .handler = ipgre_rcv, 1292 .handler = ipgre_rcv,
1293 .err_handler = ipgre_err, 1293 .err_handler = ipgre_err,
1294 .netns_ok = 1, 1294 .netns_ok = 1,
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index db46b4b5b2b9..6c98b43badf4 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -202,7 +202,7 @@ static int ip_local_deliver_finish(struct sk_buff *skb)
202 { 202 {
203 int protocol = ip_hdr(skb)->protocol; 203 int protocol = ip_hdr(skb)->protocol;
204 int hash, raw; 204 int hash, raw;
205 struct net_protocol *ipprot; 205 const struct net_protocol *ipprot;
206 206
207 resubmit: 207 resubmit:
208 raw = raw_local_deliver(skb, protocol); 208 raw = raw_local_deliver(skb, protocol);
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 3262ce06294c..38fbf04150ae 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -146,7 +146,7 @@ static const struct xfrm_type ipcomp_type = {
146 .output = ipcomp_output 146 .output = ipcomp_output
147}; 147};
148 148
149static struct net_protocol ipcomp4_protocol = { 149static const struct net_protocol ipcomp4_protocol = {
150 .handler = xfrm4_rcv, 150 .handler = xfrm4_rcv,
151 .err_handler = ipcomp4_err, 151 .err_handler = ipcomp4_err,
152 .no_policy = 1, 152 .no_policy = 1,
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 65d421cf5bc7..c43ec2d51ce2 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -99,10 +99,6 @@ static int ipmr_cache_report(struct net *net,
99 struct sk_buff *pkt, vifi_t vifi, int assert); 99 struct sk_buff *pkt, vifi_t vifi, int assert);
100static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm); 100static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm);
101 101
102#ifdef CONFIG_IP_PIMSM_V2
103static struct net_protocol pim_protocol;
104#endif
105
106static struct timer_list ipmr_expire_timer; 102static struct timer_list ipmr_expire_timer;
107 103
108/* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */ 104/* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */
@@ -1945,7 +1941,7 @@ static const struct file_operations ipmr_mfc_fops = {
1945#endif 1941#endif
1946 1942
1947#ifdef CONFIG_IP_PIMSM_V2 1943#ifdef CONFIG_IP_PIMSM_V2
1948static struct net_protocol pim_protocol = { 1944static const struct net_protocol pim_protocol = {
1949 .handler = pim_rcv, 1945 .handler = pim_rcv,
1950 .netns_ok = 1, 1946 .netns_ok = 1,
1951}; 1947};
diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c
index a2e5fc0a15e1..542f22fc98b3 100644
--- a/net/ipv4/protocol.c
+++ b/net/ipv4/protocol.c
@@ -28,14 +28,14 @@
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <net/protocol.h> 29#include <net/protocol.h>
30 30
31struct net_protocol *inet_protos[MAX_INET_PROTOS] ____cacheline_aligned_in_smp; 31const struct net_protocol *inet_protos[MAX_INET_PROTOS] ____cacheline_aligned_in_smp;
32static DEFINE_SPINLOCK(inet_proto_lock); 32static DEFINE_SPINLOCK(inet_proto_lock);
33 33
34/* 34/*
35 * Add a protocol handler to the hash tables 35 * Add a protocol handler to the hash tables
36 */ 36 */
37 37
38int inet_add_protocol(struct net_protocol *prot, unsigned char protocol) 38int inet_add_protocol(const struct net_protocol *prot, unsigned char protocol)
39{ 39{
40 int hash, ret; 40 int hash, ret;
41 41
@@ -57,7 +57,7 @@ int inet_add_protocol(struct net_protocol *prot, unsigned char protocol)
57 * Remove a protocol from the hash tables. 57 * Remove a protocol from the hash tables.
58 */ 58 */
59 59
60int inet_del_protocol(struct net_protocol *prot, unsigned char protocol) 60int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol)
61{ 61{
62 int hash, ret; 62 int hash, ret;
63 63
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index edeea060db44..19a0612b8a20 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2012,7 +2012,7 @@ int tcp_disconnect(struct sock *sk, int flags)
2012 tp->snd_cwnd = 2; 2012 tp->snd_cwnd = 2;
2013 icsk->icsk_probes_out = 0; 2013 icsk->icsk_probes_out = 0;
2014 tp->packets_out = 0; 2014 tp->packets_out = 0;
2015 tp->snd_ssthresh = 0x7fffffff; 2015 tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
2016 tp->snd_cwnd_cnt = 0; 2016 tp->snd_cwnd_cnt = 0;
2017 tp->bytes_acked = 0; 2017 tp->bytes_acked = 0;
2018 tcp_set_ca_state(sk, TCP_CA_Open); 2018 tcp_set_ca_state(sk, TCP_CA_Open);
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index af6d6fa00db1..d86784be7ab3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -761,7 +761,7 @@ void tcp_update_metrics(struct sock *sk)
761 set_dst_metric_rtt(dst, RTAX_RTTVAR, var); 761 set_dst_metric_rtt(dst, RTAX_RTTVAR, var);
762 } 762 }
763 763
764 if (tp->snd_ssthresh >= 0xFFFF) { 764 if (tcp_in_initial_slowstart(tp)) {
765 /* Slow start still did not finish. */ 765 /* Slow start still did not finish. */
766 if (dst_metric(dst, RTAX_SSTHRESH) && 766 if (dst_metric(dst, RTAX_SSTHRESH) &&
767 !dst_metric_locked(dst, RTAX_SSTHRESH) && 767 !dst_metric_locked(dst, RTAX_SSTHRESH) &&
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0543561da999..7cda24b53f61 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1808,7 +1808,7 @@ static int tcp_v4_init_sock(struct sock *sk)
1808 /* See draft-stevens-tcpca-spec-01 for discussion of the 1808 /* See draft-stevens-tcpca-spec-01 for discussion of the
1809 * initialization of these values. 1809 * initialization of these values.
1810 */ 1810 */
1811 tp->snd_ssthresh = 0x7fffffff; /* Infinity */ 1811 tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
1812 tp->snd_cwnd_clamp = ~0; 1812 tp->snd_cwnd_clamp = ~0;
1813 tp->mss_cache = 536; 1813 tp->mss_cache = 536;
1814 1814
@@ -2284,7 +2284,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len)
2284 jiffies_to_clock_t(icsk->icsk_ack.ato), 2284 jiffies_to_clock_t(icsk->icsk_ack.ato),
2285 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong, 2285 (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
2286 tp->snd_cwnd, 2286 tp->snd_cwnd,
2287 tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh, 2287 tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh,
2288 len); 2288 len);
2289} 2289}
2290 2290
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index e48c37d74d77..624c3c9b3c2b 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -363,7 +363,7 @@ void tcp_twsk_destructor(struct sock *sk)
363#ifdef CONFIG_TCP_MD5SIG 363#ifdef CONFIG_TCP_MD5SIG
364 struct tcp_timewait_sock *twsk = tcp_twsk(sk); 364 struct tcp_timewait_sock *twsk = tcp_twsk(sk);
365 if (twsk->tw_md5_keylen) 365 if (twsk->tw_md5_keylen)
366 tcp_put_md5sig_pool(); 366 tcp_free_md5sig_pool();
367#endif 367#endif
368} 368}
369 369
@@ -410,7 +410,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
410 newtp->retrans_out = 0; 410 newtp->retrans_out = 0;
411 newtp->sacked_out = 0; 411 newtp->sacked_out = 0;
412 newtp->fackets_out = 0; 412 newtp->fackets_out = 0;
413 newtp->snd_ssthresh = 0x7fffffff; 413 newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
414 414
415 /* So many TCP implementations out there (incorrectly) count the 415 /* So many TCP implementations out there (incorrectly) count the
416 * initial SYN frame in their delayed-ACK and congestion control 416 * initial SYN frame in their delayed-ACK and congestion control
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c
index cb1f0e83830b..3959e0ca456a 100644
--- a/net/ipv4/tunnel4.c
+++ b/net/ipv4/tunnel4.c
@@ -132,7 +132,7 @@ static void tunnel64_err(struct sk_buff *skb, u32 info)
132} 132}
133#endif 133#endif
134 134
135static struct net_protocol tunnel4_protocol = { 135static const struct net_protocol tunnel4_protocol = {
136 .handler = tunnel4_rcv, 136 .handler = tunnel4_rcv,
137 .err_handler = tunnel4_err, 137 .err_handler = tunnel4_err,
138 .no_policy = 1, 138 .no_policy = 1,
@@ -140,7 +140,7 @@ static struct net_protocol tunnel4_protocol = {
140}; 140};
141 141
142#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 142#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
143static struct net_protocol tunnel64_protocol = { 143static const struct net_protocol tunnel64_protocol = {
144 .handler = tunnel64_rcv, 144 .handler = tunnel64_rcv,
145 .err_handler = tunnel64_err, 145 .err_handler = tunnel64_err,
146 .no_policy = 1, 146 .no_policy = 1,
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index c784891cb7e5..95248d7f75ec 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -25,7 +25,7 @@ static void udplite_err(struct sk_buff *skb, u32 info)
25 __udp4_lib_err(skb, info, &udplite_table); 25 __udp4_lib_err(skb, info, &udplite_table);
26} 26}
27 27
28static struct net_protocol udplite_protocol = { 28static const struct net_protocol udplite_protocol = {
29 .handler = udplite_rcv, 29 .handler = udplite_rcv,
30 .err_handler = udplite_err, 30 .err_handler = udplite_err,
31 .no_policy = 1, 31 .no_policy = 1,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c9b369034a40..55f486d89c88 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -137,6 +137,8 @@ static DEFINE_SPINLOCK(addrconf_verify_lock);
137static void addrconf_join_anycast(struct inet6_ifaddr *ifp); 137static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
138static void addrconf_leave_anycast(struct inet6_ifaddr *ifp); 138static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);
139 139
140static void addrconf_bonding_change(struct net_device *dev,
141 unsigned long event);
140static int addrconf_ifdown(struct net_device *dev, int how); 142static int addrconf_ifdown(struct net_device *dev, int how);
141 143
142static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags); 144static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags);
@@ -1405,8 +1407,8 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1405 struct inet6_dev *idev = ifp->idev; 1407 struct inet6_dev *idev = ifp->idev;
1406 1408
1407 if (net_ratelimit()) 1409 if (net_ratelimit())
1408 printk(KERN_INFO "%s: IPv6 duplicate address detected!\n", 1410 printk(KERN_INFO "%s: IPv6 duplicate address %pI6c detected!\n",
1409 ifp->idev->dev->name); 1411 ifp->idev->dev->name, &ifp->addr);
1410 1412
1411 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) { 1413 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
1412 struct in6_addr addr; 1414 struct in6_addr addr;
@@ -2582,6 +2584,10 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2582 return notifier_from_errno(err); 2584 return notifier_from_errno(err);
2583 } 2585 }
2584 break; 2586 break;
2587 case NETDEV_BONDING_OLDTYPE:
2588 case NETDEV_BONDING_NEWTYPE:
2589 addrconf_bonding_change(dev, event);
2590 break;
2585 } 2591 }
2586 2592
2587 return NOTIFY_OK; 2593 return NOTIFY_OK;
@@ -2595,6 +2601,19 @@ static struct notifier_block ipv6_dev_notf = {
2595 .priority = 0 2601 .priority = 0
2596}; 2602};
2597 2603
2604static void addrconf_bonding_change(struct net_device *dev, unsigned long event)
2605{
2606 struct inet6_dev *idev;
2607 ASSERT_RTNL();
2608
2609 idev = __in6_dev_get(dev);
2610
2611 if (event == NETDEV_BONDING_NEWTYPE)
2612 ipv6_mc_remap(idev);
2613 else if (event == NETDEV_BONDING_OLDTYPE)
2614 ipv6_mc_unmap(idev);
2615}
2616
2598static int addrconf_ifdown(struct net_device *dev, int how) 2617static int addrconf_ifdown(struct net_device *dev, int how)
2599{ 2618{
2600 struct inet6_dev *idev; 2619 struct inet6_dev *idev;
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index a123a328aeb3..e127a32f9540 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -710,7 +710,7 @@ EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
710 710
711static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto) 711static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
712{ 712{
713 struct inet6_protocol *ops = NULL; 713 const struct inet6_protocol *ops = NULL;
714 714
715 for (;;) { 715 for (;;) {
716 struct ipv6_opt_hdr *opth; 716 struct ipv6_opt_hdr *opth;
@@ -745,7 +745,7 @@ static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
745static int ipv6_gso_send_check(struct sk_buff *skb) 745static int ipv6_gso_send_check(struct sk_buff *skb)
746{ 746{
747 struct ipv6hdr *ipv6h; 747 struct ipv6hdr *ipv6h;
748 struct inet6_protocol *ops; 748 const struct inet6_protocol *ops;
749 int err = -EINVAL; 749 int err = -EINVAL;
750 750
751 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) 751 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
@@ -773,7 +773,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features)
773{ 773{
774 struct sk_buff *segs = ERR_PTR(-EINVAL); 774 struct sk_buff *segs = ERR_PTR(-EINVAL);
775 struct ipv6hdr *ipv6h; 775 struct ipv6hdr *ipv6h;
776 struct inet6_protocol *ops; 776 const struct inet6_protocol *ops;
777 int proto; 777 int proto;
778 struct frag_hdr *fptr; 778 struct frag_hdr *fptr;
779 unsigned int unfrag_ip6hlen; 779 unsigned int unfrag_ip6hlen;
@@ -840,7 +840,7 @@ struct ipv6_gro_cb {
840static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, 840static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
841 struct sk_buff *skb) 841 struct sk_buff *skb)
842{ 842{
843 struct inet6_protocol *ops; 843 const struct inet6_protocol *ops;
844 struct sk_buff **pp = NULL; 844 struct sk_buff **pp = NULL;
845 struct sk_buff *p; 845 struct sk_buff *p;
846 struct ipv6hdr *iph; 846 struct ipv6hdr *iph;
@@ -926,7 +926,7 @@ out:
926 926
927static int ipv6_gro_complete(struct sk_buff *skb) 927static int ipv6_gro_complete(struct sk_buff *skb)
928{ 928{
929 struct inet6_protocol *ops; 929 const struct inet6_protocol *ops;
930 struct ipv6hdr *iph = ipv6_hdr(skb); 930 struct ipv6hdr *iph = ipv6_hdr(skb);
931 int err = -ENOSYS; 931 int err = -ENOSYS;
932 932
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 86f42a288c4b..c1589e2f1dc9 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -527,7 +527,7 @@ static const struct xfrm_type ah6_type =
527 .hdr_offset = xfrm6_find_1stfragopt, 527 .hdr_offset = xfrm6_find_1stfragopt,
528}; 528};
529 529
530static struct inet6_protocol ah6_protocol = { 530static const struct inet6_protocol ah6_protocol = {
531 .handler = xfrm6_rcv, 531 .handler = xfrm6_rcv,
532 .err_handler = ah6_err, 532 .err_handler = ah6_err,
533 .flags = INET6_PROTO_NOPOLICY, 533 .flags = INET6_PROTO_NOPOLICY,
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 678bb95b1525..af597c73ebe9 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -558,7 +558,7 @@ static const struct xfrm_type esp6_type =
558 .hdr_offset = xfrm6_find_1stfragopt, 558 .hdr_offset = xfrm6_find_1stfragopt,
559}; 559};
560 560
561static struct inet6_protocol esp6_protocol = { 561static const struct inet6_protocol esp6_protocol = {
562 .handler = xfrm6_rcv, 562 .handler = xfrm6_rcv,
563 .err_handler = esp6_err, 563 .err_handler = esp6_err,
564 .flags = INET6_PROTO_NOPOLICY, 564 .flags = INET6_PROTO_NOPOLICY,
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 4aae658e5501..df159fffe4bc 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -500,17 +500,17 @@ unknown_rh:
500 return -1; 500 return -1;
501} 501}
502 502
503static struct inet6_protocol rthdr_protocol = { 503static const struct inet6_protocol rthdr_protocol = {
504 .handler = ipv6_rthdr_rcv, 504 .handler = ipv6_rthdr_rcv,
505 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, 505 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
506}; 506};
507 507
508static struct inet6_protocol destopt_protocol = { 508static const struct inet6_protocol destopt_protocol = {
509 .handler = ipv6_destopt_rcv, 509 .handler = ipv6_destopt_rcv,
510 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, 510 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR,
511}; 511};
512 512
513static struct inet6_protocol nodata_protocol = { 513static const struct inet6_protocol nodata_protocol = {
514 .handler = dst_discard, 514 .handler = dst_discard,
515 .flags = INET6_PROTO_NOPOLICY, 515 .flags = INET6_PROTO_NOPOLICY,
516}; 516};
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index e2325f6a05fb..f23ebbec0631 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -86,7 +86,7 @@ static inline struct sock *icmpv6_sk(struct net *net)
86 86
87static int icmpv6_rcv(struct sk_buff *skb); 87static int icmpv6_rcv(struct sk_buff *skb);
88 88
89static struct inet6_protocol icmpv6_protocol = { 89static const struct inet6_protocol icmpv6_protocol = {
90 .handler = icmpv6_rcv, 90 .handler = icmpv6_rcv,
91 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 91 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
92}; 92};
@@ -583,7 +583,7 @@ out:
583 583
584static void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info) 584static void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info)
585{ 585{
586 struct inet6_protocol *ipprot; 586 const struct inet6_protocol *ipprot;
587 int inner_offset; 587 int inner_offset;
588 int hash; 588 int hash;
589 u8 nexthdr; 589 u8 nexthdr;
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 2d9cbaa67edb..237e2dba6e94 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -159,7 +159,7 @@ drop:
159 159
160static int ip6_input_finish(struct sk_buff *skb) 160static int ip6_input_finish(struct sk_buff *skb)
161{ 161{
162 struct inet6_protocol *ipprot; 162 const struct inet6_protocol *ipprot;
163 unsigned int nhoff; 163 unsigned int nhoff;
164 int nexthdr, raw; 164 int nexthdr, raw;
165 u8 hash; 165 u8 hash;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 5c8d73730c75..3907510c2ce3 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -83,10 +83,6 @@ static int ip6mr_cache_report(struct net *net, struct sk_buff *pkt,
83static int ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm); 83static int ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm);
84static void mroute_clean_tables(struct net *net); 84static void mroute_clean_tables(struct net *net);
85 85
86#ifdef CONFIG_IPV6_PIMSM_V2
87static struct inet6_protocol pim6_protocol;
88#endif
89
90static struct timer_list ipmr_expire_timer; 86static struct timer_list ipmr_expire_timer;
91 87
92 88
@@ -410,7 +406,7 @@ static int pim6_rcv(struct sk_buff *skb)
410 return 0; 406 return 0;
411} 407}
412 408
413static struct inet6_protocol pim6_protocol = { 409static const struct inet6_protocol pim6_protocol = {
414 .handler = pim6_rcv, 410 .handler = pim6_rcv,
415}; 411};
416 412
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 79c172f1ff01..2f2a5ca2c878 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -178,7 +178,7 @@ static const struct xfrm_type ipcomp6_type =
178 .hdr_offset = xfrm6_find_1stfragopt, 178 .hdr_offset = xfrm6_find_1stfragopt,
179}; 179};
180 180
181static struct inet6_protocol ipcomp6_protocol = 181static const struct inet6_protocol ipcomp6_protocol =
182{ 182{
183 .handler = xfrm6_rcv, 183 .handler = xfrm6_rcv,
184 .err_handler = ipcomp6_err, 184 .err_handler = ipcomp6_err,
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 71c3dacec1ed..f9fcf690bd5d 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -2249,6 +2249,25 @@ static void igmp6_timer_handler(unsigned long data)
2249 ma_put(ma); 2249 ma_put(ma);
2250} 2250}
2251 2251
2252/* Device changing type */
2253
2254void ipv6_mc_unmap(struct inet6_dev *idev)
2255{
2256 struct ifmcaddr6 *i;
2257
2258 /* Install multicast list, except for all-nodes (already installed) */
2259
2260 read_lock_bh(&idev->lock);
2261 for (i = idev->mc_list; i; i = i->next)
2262 igmp6_group_dropped(i);
2263 read_unlock_bh(&idev->lock);
2264}
2265
2266void ipv6_mc_remap(struct inet6_dev *idev)
2267{
2268 ipv6_mc_up(idev);
2269}
2270
2252/* Device going down */ 2271/* Device going down */
2253 2272
2254void ipv6_mc_down(struct inet6_dev *idev) 2273void ipv6_mc_down(struct inet6_dev *idev)
diff --git a/net/ipv6/protocol.c b/net/ipv6/protocol.c
index 568864f722ca..1fa3468f0f32 100644
--- a/net/ipv6/protocol.c
+++ b/net/ipv6/protocol.c
@@ -25,11 +25,11 @@
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <net/protocol.h> 26#include <net/protocol.h>
27 27
28struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; 28const struct inet6_protocol *inet6_protos[MAX_INET_PROTOS];
29static DEFINE_SPINLOCK(inet6_proto_lock); 29static DEFINE_SPINLOCK(inet6_proto_lock);
30 30
31 31
32int inet6_add_protocol(struct inet6_protocol *prot, unsigned char protocol) 32int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char protocol)
33{ 33{
34 int ret, hash = protocol & (MAX_INET_PROTOS - 1); 34 int ret, hash = protocol & (MAX_INET_PROTOS - 1);
35 35
@@ -53,7 +53,7 @@ EXPORT_SYMBOL(inet6_add_protocol);
53 * Remove a protocol from the hash tables. 53 * Remove a protocol from the hash tables.
54 */ 54 */
55 55
56int inet6_del_protocol(struct inet6_protocol *prot, unsigned char protocol) 56int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char protocol)
57{ 57{
58 int ret, hash = protocol & (MAX_INET_PROTOS - 1); 58 int ret, hash = protocol & (MAX_INET_PROTOS - 1);
59 59
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 2642a41a8535..da5bd0ed83df 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -627,7 +627,7 @@ fail_hdr:
627 return -1; 627 return -1;
628} 628}
629 629
630static struct inet6_protocol frag_protocol = 630static const struct inet6_protocol frag_protocol =
631{ 631{
632 .handler = ipv6_frag_rcv, 632 .handler = ipv6_frag_rcv,
633 .flags = INET6_PROTO_NOPOLICY, 633 .flags = INET6_PROTO_NOPOLICY,
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9ccfef345560..77aecbe8ff6c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -481,7 +481,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
481 481
482 pref = rinfo->route_pref; 482 pref = rinfo->route_pref;
483 if (pref == ICMPV6_ROUTER_PREF_INVALID) 483 if (pref == ICMPV6_ROUTER_PREF_INVALID)
484 pref = ICMPV6_ROUTER_PREF_MEDIUM; 484 return -EINVAL;
485 485
486 lifetime = addrconf_timeout_fixup(ntohl(rinfo->lifetime), HZ); 486 lifetime = addrconf_timeout_fixup(ntohl(rinfo->lifetime), HZ);
487 487
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3aae0f217d61..21d100b68b19 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1846,7 +1846,7 @@ static int tcp_v6_init_sock(struct sock *sk)
1846 /* See draft-stevens-tcpca-spec-01 for discussion of the 1846 /* See draft-stevens-tcpca-spec-01 for discussion of the
1847 * initialization of these values. 1847 * initialization of these values.
1848 */ 1848 */
1849 tp->snd_ssthresh = 0x7fffffff; 1849 tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
1850 tp->snd_cwnd_clamp = ~0; 1850 tp->snd_cwnd_clamp = ~0;
1851 tp->mss_cache = 536; 1851 tp->mss_cache = 536;
1852 1852
@@ -1969,7 +1969,8 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
1969 jiffies_to_clock_t(icsk->icsk_rto), 1969 jiffies_to_clock_t(icsk->icsk_rto),
1970 jiffies_to_clock_t(icsk->icsk_ack.ato), 1970 jiffies_to_clock_t(icsk->icsk_ack.ato),
1971 (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong, 1971 (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong,
1972 tp->snd_cwnd, tp->snd_ssthresh>=0xFFFF?-1:tp->snd_ssthresh 1972 tp->snd_cwnd,
1973 tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh
1973 ); 1974 );
1974} 1975}
1975 1976
@@ -2093,7 +2094,7 @@ struct proto tcpv6_prot = {
2093#endif 2094#endif
2094}; 2095};
2095 2096
2096static struct inet6_protocol tcpv6_protocol = { 2097static const struct inet6_protocol tcpv6_protocol = {
2097 .handler = tcp_v6_rcv, 2098 .handler = tcp_v6_rcv,
2098 .err_handler = tcp_v6_err, 2099 .err_handler = tcp_v6_err,
2099 .gso_send_check = tcp_v6_gso_send_check, 2100 .gso_send_check = tcp_v6_gso_send_check,
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c
index 633ad789effc..51e2832d13a6 100644
--- a/net/ipv6/tunnel6.c
+++ b/net/ipv6/tunnel6.c
@@ -133,13 +133,13 @@ static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
133 break; 133 break;
134} 134}
135 135
136static struct inet6_protocol tunnel6_protocol = { 136static const struct inet6_protocol tunnel6_protocol = {
137 .handler = tunnel6_rcv, 137 .handler = tunnel6_rcv,
138 .err_handler = tunnel6_err, 138 .err_handler = tunnel6_err,
139 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 139 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
140}; 140};
141 141
142static struct inet6_protocol tunnel46_protocol = { 142static const struct inet6_protocol tunnel46_protocol = {
143 .handler = tunnel46_rcv, 143 .handler = tunnel46_rcv,
144 .err_handler = tunnel6_err, 144 .err_handler = tunnel6_err,
145 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 145 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 164040613c2e..b265b7047d3e 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1172,7 +1172,7 @@ out:
1172 return segs; 1172 return segs;
1173} 1173}
1174 1174
1175static struct inet6_protocol udpv6_protocol = { 1175static const struct inet6_protocol udpv6_protocol = {
1176 .handler = udpv6_rcv, 1176 .handler = udpv6_rcv,
1177 .err_handler = udpv6_err, 1177 .err_handler = udpv6_err,
1178 .gso_send_check = udp6_ufo_send_check, 1178 .gso_send_check = udp6_ufo_send_check,
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 4818c48688f2..d737a27ee010 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -25,7 +25,7 @@ static void udplitev6_err(struct sk_buff *skb,
25 __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table); 25 __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table);
26} 26}
27 27
28static struct inet6_protocol udplitev6_protocol = { 28static const struct inet6_protocol udplitev6_protocol = {
29 .handler = udplitev6_rcv, 29 .handler = udplitev6_rcv,
30 .err_handler = udplitev6_err, 30 .err_handler = udplitev6_err,
31 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, 31 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 49c15b48408e..d985d163dcfc 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -34,7 +34,7 @@
34 34
35static char iucv_userid[80]; 35static char iucv_userid[80];
36 36
37static struct proto_ops iucv_sock_ops; 37static const struct proto_ops iucv_sock_ops;
38 38
39static struct proto iucv_proto = { 39static struct proto iucv_proto = {
40 .name = "AF_IUCV", 40 .name = "AF_IUCV",
@@ -59,8 +59,8 @@ do { \
59 DEFINE_WAIT(__wait); \ 59 DEFINE_WAIT(__wait); \
60 long __timeo = timeo; \ 60 long __timeo = timeo; \
61 ret = 0; \ 61 ret = 0; \
62 prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \
62 while (!(condition)) { \ 63 while (!(condition)) { \
63 prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \
64 if (!__timeo) { \ 64 if (!__timeo) { \
65 ret = -EAGAIN; \ 65 ret = -EAGAIN; \
66 break; \ 66 break; \
@@ -361,10 +361,9 @@ static void iucv_sock_cleanup_listen(struct sock *parent)
361 } 361 }
362 362
363 parent->sk_state = IUCV_CLOSED; 363 parent->sk_state = IUCV_CLOSED;
364 sock_set_flag(parent, SOCK_ZAPPED);
365} 364}
366 365
367/* Kill socket */ 366/* Kill socket (only if zapped and orphaned) */
368static void iucv_sock_kill(struct sock *sk) 367static void iucv_sock_kill(struct sock *sk)
369{ 368{
370 if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) 369 if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
@@ -426,17 +425,18 @@ static void iucv_sock_close(struct sock *sk)
426 425
427 skb_queue_purge(&iucv->send_skb_q); 426 skb_queue_purge(&iucv->send_skb_q);
428 skb_queue_purge(&iucv->backlog_skb_q); 427 skb_queue_purge(&iucv->backlog_skb_q);
429
430 sock_set_flag(sk, SOCK_ZAPPED);
431 break; 428 break;
432 429
433 default: 430 default:
434 sock_set_flag(sk, SOCK_ZAPPED); 431 sock_set_flag(sk, SOCK_ZAPPED);
432 /* nothing to do here */
435 break; 433 break;
436 } 434 }
437 435
436 /* mark socket for deletion by iucv_sock_kill() */
437 sock_set_flag(sk, SOCK_ZAPPED);
438
438 release_sock(sk); 439 release_sock(sk);
439 iucv_sock_kill(sk);
440} 440}
441 441
442static void iucv_sock_init(struct sock *sk, struct sock *parent) 442static void iucv_sock_init(struct sock *sk, struct sock *parent)
@@ -569,6 +569,7 @@ struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock)
569 569
570 if (sk->sk_state == IUCV_CONNECTED || 570 if (sk->sk_state == IUCV_CONNECTED ||
571 sk->sk_state == IUCV_SEVERED || 571 sk->sk_state == IUCV_SEVERED ||
572 sk->sk_state == IUCV_DISCONN || /* due to PM restore */
572 !newsock) { 573 !newsock) {
573 iucv_accept_unlink(sk); 574 iucv_accept_unlink(sk);
574 if (newsock) 575 if (newsock)
@@ -1035,6 +1036,10 @@ out:
1035 return err; 1036 return err;
1036} 1037}
1037 1038
1039/* iucv_fragment_skb() - Fragment a single IUCV message into multiple skb's
1040 *
1041 * Locking: must be called with message_q.lock held
1042 */
1038static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len) 1043static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len)
1039{ 1044{
1040 int dataleft, size, copied = 0; 1045 int dataleft, size, copied = 0;
@@ -1069,6 +1074,10 @@ static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len)
1069 return 0; 1074 return 0;
1070} 1075}
1071 1076
1077/* iucv_process_message() - Receive a single outstanding IUCV message
1078 *
1079 * Locking: must be called with message_q.lock held
1080 */
1072static void iucv_process_message(struct sock *sk, struct sk_buff *skb, 1081static void iucv_process_message(struct sock *sk, struct sk_buff *skb,
1073 struct iucv_path *path, 1082 struct iucv_path *path,
1074 struct iucv_message *msg) 1083 struct iucv_message *msg)
@@ -1119,6 +1128,10 @@ static void iucv_process_message(struct sock *sk, struct sk_buff *skb,
1119 skb_queue_head(&iucv_sk(sk)->backlog_skb_q, skb); 1128 skb_queue_head(&iucv_sk(sk)->backlog_skb_q, skb);
1120} 1129}
1121 1130
1131/* iucv_process_message_q() - Process outstanding IUCV messages
1132 *
1133 * Locking: must be called with message_q.lock held
1134 */
1122static void iucv_process_message_q(struct sock *sk) 1135static void iucv_process_message_q(struct sock *sk)
1123{ 1136{
1124 struct iucv_sock *iucv = iucv_sk(sk); 1137 struct iucv_sock *iucv = iucv_sk(sk);
@@ -1209,6 +1222,7 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
1209 kfree_skb(skb); 1222 kfree_skb(skb);
1210 1223
1211 /* Queue backlog skbs */ 1224 /* Queue backlog skbs */
1225 spin_lock_bh(&iucv->message_q.lock);
1212 rskb = skb_dequeue(&iucv->backlog_skb_q); 1226 rskb = skb_dequeue(&iucv->backlog_skb_q);
1213 while (rskb) { 1227 while (rskb) {
1214 if (sock_queue_rcv_skb(sk, rskb)) { 1228 if (sock_queue_rcv_skb(sk, rskb)) {
@@ -1220,11 +1234,10 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
1220 } 1234 }
1221 } 1235 }
1222 if (skb_queue_empty(&iucv->backlog_skb_q)) { 1236 if (skb_queue_empty(&iucv->backlog_skb_q)) {
1223 spin_lock_bh(&iucv->message_q.lock);
1224 if (!list_empty(&iucv->message_q.list)) 1237 if (!list_empty(&iucv->message_q.list))
1225 iucv_process_message_q(sk); 1238 iucv_process_message_q(sk);
1226 spin_unlock_bh(&iucv->message_q.lock);
1227 } 1239 }
1240 spin_unlock_bh(&iucv->message_q.lock);
1228 } 1241 }
1229 1242
1230done: 1243done:
@@ -1682,7 +1695,7 @@ static void iucv_callback_shutdown(struct iucv_path *path, u8 ipuser[16])
1682 bh_unlock_sock(sk); 1695 bh_unlock_sock(sk);
1683} 1696}
1684 1697
1685static struct proto_ops iucv_sock_ops = { 1698static const struct proto_ops iucv_sock_ops = {
1686 .family = PF_IUCV, 1699 .family = PF_IUCV,
1687 .owner = THIS_MODULE, 1700 .owner = THIS_MODULE,
1688 .release = iucv_sock_release, 1701 .release = iucv_sock_release,
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index c833481d32e3..3973d0e61e56 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -79,6 +79,14 @@ static int iucv_bus_match(struct device *dev, struct device_driver *drv)
79 return 0; 79 return 0;
80} 80}
81 81
82enum iucv_pm_states {
83 IUCV_PM_INITIAL = 0,
84 IUCV_PM_FREEZING = 1,
85 IUCV_PM_THAWING = 2,
86 IUCV_PM_RESTORING = 3,
87};
88static enum iucv_pm_states iucv_pm_state;
89
82static int iucv_pm_prepare(struct device *); 90static int iucv_pm_prepare(struct device *);
83static void iucv_pm_complete(struct device *); 91static void iucv_pm_complete(struct device *);
84static int iucv_pm_freeze(struct device *); 92static int iucv_pm_freeze(struct device *);
@@ -354,7 +362,7 @@ static int iucv_query_maxconn(void)
354 " srl %0,28\n" 362 " srl %0,28\n"
355 : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc"); 363 : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc");
356 if (ccode == 0) 364 if (ccode == 0)
357 iucv_max_pathid = reg0; 365 iucv_max_pathid = reg1;
358 kfree(param); 366 kfree(param);
359 return ccode ? -EPERM : 0; 367 return ccode ? -EPERM : 0;
360} 368}
@@ -856,7 +864,7 @@ int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
856 int rc; 864 int rc;
857 865
858 local_bh_disable(); 866 local_bh_disable();
859 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 867 if (cpus_empty(iucv_buffer_cpumask)) {
860 rc = -EIO; 868 rc = -EIO;
861 goto out; 869 goto out;
862 } 870 }
@@ -905,7 +913,7 @@ int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
905 913
906 spin_lock_bh(&iucv_table_lock); 914 spin_lock_bh(&iucv_table_lock);
907 iucv_cleanup_queue(); 915 iucv_cleanup_queue();
908 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 916 if (cpus_empty(iucv_buffer_cpumask)) {
909 rc = -EIO; 917 rc = -EIO;
910 goto out; 918 goto out;
911 } 919 }
@@ -965,7 +973,7 @@ int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16])
965 int rc; 973 int rc;
966 974
967 local_bh_disable(); 975 local_bh_disable();
968 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 976 if (cpus_empty(iucv_buffer_cpumask)) {
969 rc = -EIO; 977 rc = -EIO;
970 goto out; 978 goto out;
971 } 979 }
@@ -997,7 +1005,7 @@ int iucv_path_resume(struct iucv_path *path, u8 userdata[16])
997 int rc; 1005 int rc;
998 1006
999 local_bh_disable(); 1007 local_bh_disable();
1000 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1008 if (cpus_empty(iucv_buffer_cpumask)) {
1001 rc = -EIO; 1009 rc = -EIO;
1002 goto out; 1010 goto out;
1003 } 1011 }
@@ -1026,7 +1034,7 @@ int iucv_path_sever(struct iucv_path *path, u8 userdata[16])
1026 int rc; 1034 int rc;
1027 1035
1028 preempt_disable(); 1036 preempt_disable();
1029 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1037 if (cpus_empty(iucv_buffer_cpumask)) {
1030 rc = -EIO; 1038 rc = -EIO;
1031 goto out; 1039 goto out;
1032 } 1040 }
@@ -1060,7 +1068,7 @@ int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
1060 int rc; 1068 int rc;
1061 1069
1062 local_bh_disable(); 1070 local_bh_disable();
1063 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1071 if (cpus_empty(iucv_buffer_cpumask)) {
1064 rc = -EIO; 1072 rc = -EIO;
1065 goto out; 1073 goto out;
1066 } 1074 }
@@ -1152,7 +1160,7 @@ int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1152 if (msg->flags & IUCV_IPRMDATA) 1160 if (msg->flags & IUCV_IPRMDATA)
1153 return iucv_message_receive_iprmdata(path, msg, flags, 1161 return iucv_message_receive_iprmdata(path, msg, flags,
1154 buffer, size, residual); 1162 buffer, size, residual);
1155 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1163 if (cpus_empty(iucv_buffer_cpumask)) {
1156 rc = -EIO; 1164 rc = -EIO;
1157 goto out; 1165 goto out;
1158 } 1166 }
@@ -1225,7 +1233,7 @@ int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg)
1225 int rc; 1233 int rc;
1226 1234
1227 local_bh_disable(); 1235 local_bh_disable();
1228 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1236 if (cpus_empty(iucv_buffer_cpumask)) {
1229 rc = -EIO; 1237 rc = -EIO;
1230 goto out; 1238 goto out;
1231 } 1239 }
@@ -1264,7 +1272,7 @@ int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
1264 int rc; 1272 int rc;
1265 1273
1266 local_bh_disable(); 1274 local_bh_disable();
1267 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1275 if (cpus_empty(iucv_buffer_cpumask)) {
1268 rc = -EIO; 1276 rc = -EIO;
1269 goto out; 1277 goto out;
1270 } 1278 }
@@ -1314,7 +1322,7 @@ int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1314 union iucv_param *parm; 1322 union iucv_param *parm;
1315 int rc; 1323 int rc;
1316 1324
1317 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1325 if (cpus_empty(iucv_buffer_cpumask)) {
1318 rc = -EIO; 1326 rc = -EIO;
1319 goto out; 1327 goto out;
1320 } 1328 }
@@ -1401,7 +1409,7 @@ int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
1401 int rc; 1409 int rc;
1402 1410
1403 local_bh_disable(); 1411 local_bh_disable();
1404 if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { 1412 if (cpus_empty(iucv_buffer_cpumask)) {
1405 rc = -EIO; 1413 rc = -EIO;
1406 goto out; 1414 goto out;
1407 } 1415 }
@@ -1875,6 +1883,7 @@ static int iucv_pm_freeze(struct device *dev)
1875#ifdef CONFIG_PM_DEBUG 1883#ifdef CONFIG_PM_DEBUG
1876 printk(KERN_WARNING "iucv_pm_freeze\n"); 1884 printk(KERN_WARNING "iucv_pm_freeze\n");
1877#endif 1885#endif
1886 iucv_pm_state = IUCV_PM_FREEZING;
1878 for_each_cpu_mask_nr(cpu, iucv_irq_cpumask) 1887 for_each_cpu_mask_nr(cpu, iucv_irq_cpumask)
1879 smp_call_function_single(cpu, iucv_block_cpu_almost, NULL, 1); 1888 smp_call_function_single(cpu, iucv_block_cpu_almost, NULL, 1);
1880 if (dev->driver && dev->driver->pm && dev->driver->pm->freeze) 1889 if (dev->driver && dev->driver->pm && dev->driver->pm->freeze)
@@ -1899,6 +1908,7 @@ static int iucv_pm_thaw(struct device *dev)
1899#ifdef CONFIG_PM_DEBUG 1908#ifdef CONFIG_PM_DEBUG
1900 printk(KERN_WARNING "iucv_pm_thaw\n"); 1909 printk(KERN_WARNING "iucv_pm_thaw\n");
1901#endif 1910#endif
1911 iucv_pm_state = IUCV_PM_THAWING;
1902 if (!iucv_path_table) { 1912 if (!iucv_path_table) {
1903 rc = iucv_enable(); 1913 rc = iucv_enable();
1904 if (rc) 1914 if (rc)
@@ -1933,6 +1943,10 @@ static int iucv_pm_restore(struct device *dev)
1933#ifdef CONFIG_PM_DEBUG 1943#ifdef CONFIG_PM_DEBUG
1934 printk(KERN_WARNING "iucv_pm_restore %p\n", iucv_path_table); 1944 printk(KERN_WARNING "iucv_pm_restore %p\n", iucv_path_table);
1935#endif 1945#endif
1946 if ((iucv_pm_state != IUCV_PM_RESTORING) && iucv_path_table)
1947 pr_warning("Suspending Linux did not completely close all IUCV "
1948 "connections\n");
1949 iucv_pm_state = IUCV_PM_RESTORING;
1936 if (cpus_empty(iucv_irq_cpumask)) { 1950 if (cpus_empty(iucv_irq_cpumask)) {
1937 rc = iucv_query_maxconn(); 1951 rc = iucv_query_maxconn();
1938 rc = iucv_enable(); 1952 rc = iucv_enable();
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c
index 7c5142988bbb..6e5d68b4e427 100644
--- a/net/mac80211/rc80211_minstrel.c
+++ b/net/mac80211/rc80211_minstrel.c
@@ -418,7 +418,7 @@ minstrel_rate_init(void *priv, struct ieee80211_supported_band *sband,
418 418
419 /* contention window */ 419 /* contention window */
420 tx_time_single += t_slot + min(cw, mp->cw_max); 420 tx_time_single += t_slot + min(cw, mp->cw_max);
421 cw = (cw + 1) << 1; 421 cw = (cw << 1) | 1;
422 422
423 tx_time += tx_time_single; 423 tx_time += tx_time_single;
424 tx_time_cts += tx_time_single + mi->sp_ack_dur; 424 tx_time_cts += tx_time_single + mi->sp_ack_dur;
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index d0ff382c40ca..c5aab6a368ce 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -177,9 +177,11 @@ static void netlink_sock_destruct(struct sock *sk)
177 * this, _but_ remember, it adds useless work on UP machines. 177 * this, _but_ remember, it adds useless work on UP machines.
178 */ 178 */
179 179
180static void netlink_table_grab(void) 180void netlink_table_grab(void)
181 __acquires(nl_table_lock) 181 __acquires(nl_table_lock)
182{ 182{
183 might_sleep();
184
183 write_lock_irq(&nl_table_lock); 185 write_lock_irq(&nl_table_lock);
184 186
185 if (atomic_read(&nl_table_users)) { 187 if (atomic_read(&nl_table_users)) {
@@ -200,7 +202,7 @@ static void netlink_table_grab(void)
200 } 202 }
201} 203}
202 204
203static void netlink_table_ungrab(void) 205void netlink_table_ungrab(void)
204 __releases(nl_table_lock) 206 __releases(nl_table_lock)
205{ 207{
206 write_unlock_irq(&nl_table_lock); 208 write_unlock_irq(&nl_table_lock);
@@ -1549,37 +1551,21 @@ static void netlink_free_old_listeners(struct rcu_head *rcu_head)
1549 kfree(lrh->ptr); 1551 kfree(lrh->ptr);
1550} 1552}
1551 1553
1552/** 1554int __netlink_change_ngroups(struct sock *sk, unsigned int groups)
1553 * netlink_change_ngroups - change number of multicast groups
1554 *
1555 * This changes the number of multicast groups that are available
1556 * on a certain netlink family. Note that it is not possible to
1557 * change the number of groups to below 32. Also note that it does
1558 * not implicitly call netlink_clear_multicast_users() when the
1559 * number of groups is reduced.
1560 *
1561 * @sk: The kernel netlink socket, as returned by netlink_kernel_create().
1562 * @groups: The new number of groups.
1563 */
1564int netlink_change_ngroups(struct sock *sk, unsigned int groups)
1565{ 1555{
1566 unsigned long *listeners, *old = NULL; 1556 unsigned long *listeners, *old = NULL;
1567 struct listeners_rcu_head *old_rcu_head; 1557 struct listeners_rcu_head *old_rcu_head;
1568 struct netlink_table *tbl = &nl_table[sk->sk_protocol]; 1558 struct netlink_table *tbl = &nl_table[sk->sk_protocol];
1569 int err = 0;
1570 1559
1571 if (groups < 32) 1560 if (groups < 32)
1572 groups = 32; 1561 groups = 32;
1573 1562
1574 netlink_table_grab();
1575 if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) { 1563 if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) {
1576 listeners = kzalloc(NLGRPSZ(groups) + 1564 listeners = kzalloc(NLGRPSZ(groups) +
1577 sizeof(struct listeners_rcu_head), 1565 sizeof(struct listeners_rcu_head),
1578 GFP_ATOMIC); 1566 GFP_ATOMIC);
1579 if (!listeners) { 1567 if (!listeners)
1580 err = -ENOMEM; 1568 return -ENOMEM;
1581 goto out_ungrab;
1582 }
1583 old = tbl->listeners; 1569 old = tbl->listeners;
1584 memcpy(listeners, old, NLGRPSZ(tbl->groups)); 1570 memcpy(listeners, old, NLGRPSZ(tbl->groups));
1585 rcu_assign_pointer(tbl->listeners, listeners); 1571 rcu_assign_pointer(tbl->listeners, listeners);
@@ -1597,8 +1583,29 @@ int netlink_change_ngroups(struct sock *sk, unsigned int groups)
1597 } 1583 }
1598 tbl->groups = groups; 1584 tbl->groups = groups;
1599 1585
1600 out_ungrab: 1586 return 0;
1587}
1588
1589/**
1590 * netlink_change_ngroups - change number of multicast groups
1591 *
1592 * This changes the number of multicast groups that are available
1593 * on a certain netlink family. Note that it is not possible to
1594 * change the number of groups to below 32. Also note that it does
1595 * not implicitly call netlink_clear_multicast_users() when the
1596 * number of groups is reduced.
1597 *
1598 * @sk: The kernel netlink socket, as returned by netlink_kernel_create().
1599 * @groups: The new number of groups.
1600 */
1601int netlink_change_ngroups(struct sock *sk, unsigned int groups)
1602{
1603 int err;
1604
1605 netlink_table_grab();
1606 err = __netlink_change_ngroups(sk, groups);
1601 netlink_table_ungrab(); 1607 netlink_table_ungrab();
1608
1602 return err; 1609 return err;
1603} 1610}
1604 1611
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 66f6ba0bab11..566941e03363 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -176,9 +176,10 @@ int genl_register_mc_group(struct genl_family *family,
176 if (family->netnsok) { 176 if (family->netnsok) {
177 struct net *net; 177 struct net *net;
178 178
179 netlink_table_grab();
179 rcu_read_lock(); 180 rcu_read_lock();
180 for_each_net_rcu(net) { 181 for_each_net_rcu(net) {
181 err = netlink_change_ngroups(net->genl_sock, 182 err = __netlink_change_ngroups(net->genl_sock,
182 mc_groups_longs * BITS_PER_LONG); 183 mc_groups_longs * BITS_PER_LONG);
183 if (err) { 184 if (err) {
184 /* 185 /*
@@ -188,10 +189,12 @@ int genl_register_mc_group(struct genl_family *family,
188 * increased on some sockets which is ok. 189 * increased on some sockets which is ok.
189 */ 190 */
190 rcu_read_unlock(); 191 rcu_read_unlock();
192 netlink_table_ungrab();
191 goto out; 193 goto out;
192 } 194 }
193 } 195 }
194 rcu_read_unlock(); 196 rcu_read_unlock();
197 netlink_table_ungrab();
195 } else { 198 } else {
196 err = netlink_change_ngroups(init_net.genl_sock, 199 err = netlink_change_ngroups(init_net.genl_sock,
197 mc_groups_longs * BITS_PER_LONG); 200 mc_groups_longs * BITS_PER_LONG);
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 2f65dcaed2fb..5f42f30dd168 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -209,7 +209,14 @@ static int phonet_device_autoconf(struct net_device *dev)
209 SIOCPNGAUTOCONF); 209 SIOCPNGAUTOCONF);
210 if (ret < 0) 210 if (ret < 0)
211 return ret; 211 return ret;
212 return phonet_address_add(dev, req.ifr_phonet_autoconf.device); 212
213 ASSERT_RTNL();
214 ret = phonet_address_add(dev, req.ifr_phonet_autoconf.device);
215 if (ret)
216 return ret;
217 phonet_address_notify(RTM_NEWADDR, dev,
218 req.ifr_phonet_autoconf.device);
219 return 0;
213} 220}
214 221
215/* notify Phonet of device events */ 222/* notify Phonet of device events */
diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c
index 108ed2e671c5..6b58aeff4c7a 100644
--- a/net/rds/af_rds.c
+++ b/net/rds/af_rds.c
@@ -359,7 +359,7 @@ static struct proto rds_proto = {
359 .obj_size = sizeof(struct rds_sock), 359 .obj_size = sizeof(struct rds_sock),
360}; 360};
361 361
362static struct proto_ops rds_proto_ops = { 362static const struct proto_ops rds_proto_ops = {
363 .family = AF_RDS, 363 .family = AF_RDS,
364 .owner = THIS_MODULE, 364 .owner = THIS_MODULE,
365 .release = rds_release, 365 .release = rds_release,
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index e5f478ca3d61..1e166c9685aa 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -63,7 +63,7 @@ int sysctl_rose_window_size = ROSE_DEFAULT_WINDOW_SIZE;
63static HLIST_HEAD(rose_list); 63static HLIST_HEAD(rose_list);
64static DEFINE_SPINLOCK(rose_list_lock); 64static DEFINE_SPINLOCK(rose_list_lock);
65 65
66static struct proto_ops rose_proto_ops; 66static const struct proto_ops rose_proto_ops;
67 67
68ax25_address rose_callsign; 68ax25_address rose_callsign;
69 69
@@ -1515,7 +1515,7 @@ static struct net_proto_family rose_family_ops = {
1515 .owner = THIS_MODULE, 1515 .owner = THIS_MODULE,
1516}; 1516};
1517 1517
1518static struct proto_ops rose_proto_ops = { 1518static const struct proto_ops rose_proto_ops = {
1519 .family = PF_ROSE, 1519 .family = PF_ROSE,
1520 .owner = THIS_MODULE, 1520 .owner = THIS_MODULE,
1521 .release = rose_release, 1521 .release = rose_release,
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
index c9f1f0a3a2ff..b4a220977031 100644
--- a/net/rxrpc/ar-ack.c
+++ b/net/rxrpc/ar-ack.c
@@ -40,7 +40,7 @@ static const s8 rxrpc_ack_priority[] = {
40/* 40/*
41 * propose an ACK be sent 41 * propose an ACK be sent
42 */ 42 */
43void __rxrpc_propose_ACK(struct rxrpc_call *call, uint8_t ack_reason, 43void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
44 __be32 serial, bool immediate) 44 __be32 serial, bool immediate)
45{ 45{
46 unsigned long expiry; 46 unsigned long expiry;
@@ -120,7 +120,7 @@ cancel_timer:
120/* 120/*
121 * propose an ACK be sent, locking the call structure 121 * propose an ACK be sent, locking the call structure
122 */ 122 */
123void rxrpc_propose_ACK(struct rxrpc_call *call, uint8_t ack_reason, 123void rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
124 __be32 serial, bool immediate) 124 __be32 serial, bool immediate)
125{ 125{
126 s8 prior = rxrpc_ack_priority[ack_reason]; 126 s8 prior = rxrpc_ack_priority[ack_reason];
@@ -520,7 +520,7 @@ static void rxrpc_zap_tx_window(struct rxrpc_call *call)
520 struct rxrpc_skb_priv *sp; 520 struct rxrpc_skb_priv *sp;
521 struct sk_buff *skb; 521 struct sk_buff *skb;
522 unsigned long _skb, *acks_window; 522 unsigned long _skb, *acks_window;
523 uint8_t winsz = call->acks_winsz; 523 u8 winsz = call->acks_winsz;
524 int tail; 524 int tail;
525 525
526 acks_window = call->acks_window; 526 acks_window = call->acks_window;
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
index 3e7318c1343c..7043b294bb67 100644
--- a/net/rxrpc/ar-internal.h
+++ b/net/rxrpc/ar-internal.h
@@ -229,7 +229,7 @@ struct rxrpc_conn_bundle {
229 int debug_id; /* debug ID for printks */ 229 int debug_id; /* debug ID for printks */
230 unsigned short num_conns; /* number of connections in this bundle */ 230 unsigned short num_conns; /* number of connections in this bundle */
231 __be16 service_id; /* service ID */ 231 __be16 service_id; /* service ID */
232 uint8_t security_ix; /* security type */ 232 u8 security_ix; /* security type */
233}; 233};
234 234
235/* 235/*
@@ -370,10 +370,10 @@ struct rxrpc_call {
370 u8 channel; /* connection channel occupied by this call */ 370 u8 channel; /* connection channel occupied by this call */
371 371
372 /* transmission-phase ACK management */ 372 /* transmission-phase ACK management */
373 uint8_t acks_head; /* offset into window of first entry */ 373 u8 acks_head; /* offset into window of first entry */
374 uint8_t acks_tail; /* offset into window of last entry */ 374 u8 acks_tail; /* offset into window of last entry */
375 uint8_t acks_winsz; /* size of un-ACK'd window */ 375 u8 acks_winsz; /* size of un-ACK'd window */
376 uint8_t acks_unacked; /* lowest unacked packet in last ACK received */ 376 u8 acks_unacked; /* lowest unacked packet in last ACK received */
377 int acks_latest; /* serial number of latest ACK received */ 377 int acks_latest; /* serial number of latest ACK received */
378 rxrpc_seq_t acks_hard; /* highest definitively ACK'd msg seq */ 378 rxrpc_seq_t acks_hard; /* highest definitively ACK'd msg seq */
379 unsigned long *acks_window; /* sent packet window 379 unsigned long *acks_window; /* sent packet window
@@ -388,7 +388,7 @@ struct rxrpc_call {
388 rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */ 388 rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */
389 rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */ 389 rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */
390 rxrpc_seq_net_t ackr_prev_seq; /* previous sequence number received */ 390 rxrpc_seq_net_t ackr_prev_seq; /* previous sequence number received */
391 uint8_t ackr_reason; /* reason to ACK */ 391 u8 ackr_reason; /* reason to ACK */
392 __be32 ackr_serial; /* serial of packet being ACK'd */ 392 __be32 ackr_serial; /* serial of packet being ACK'd */
393 atomic_t ackr_not_idle; /* number of packets in Rx queue */ 393 atomic_t ackr_not_idle; /* number of packets in Rx queue */
394 394
@@ -402,22 +402,6 @@ struct rxrpc_call {
402}; 402};
403 403
404/* 404/*
405 * RxRPC key for Kerberos (type-2 security)
406 */
407struct rxkad_key {
408 u16 security_index; /* RxRPC header security index */
409 u16 ticket_len; /* length of ticket[] */
410 u32 expiry; /* time at which expires */
411 u32 kvno; /* key version number */
412 u8 session_key[8]; /* DES session key */
413 u8 ticket[0]; /* the encrypted ticket */
414};
415
416struct rxrpc_key_payload {
417 struct rxkad_key k;
418};
419
420/*
421 * locally abort an RxRPC call 405 * locally abort an RxRPC call
422 */ 406 */
423static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code) 407static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
@@ -450,8 +434,8 @@ extern int rxrpc_reject_call(struct rxrpc_sock *);
450/* 434/*
451 * ar-ack.c 435 * ar-ack.c
452 */ 436 */
453extern void __rxrpc_propose_ACK(struct rxrpc_call *, uint8_t, __be32, bool); 437extern void __rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool);
454extern void rxrpc_propose_ACK(struct rxrpc_call *, uint8_t, __be32, bool); 438extern void rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool);
455extern void rxrpc_process_call(struct work_struct *); 439extern void rxrpc_process_call(struct work_struct *);
456 440
457/* 441/*
diff --git a/net/rxrpc/ar-key.c b/net/rxrpc/ar-key.c
index ad8c7a782da1..74697b200496 100644
--- a/net/rxrpc/ar-key.c
+++ b/net/rxrpc/ar-key.c
@@ -17,6 +17,7 @@
17#include <linux/skbuff.h> 17#include <linux/skbuff.h>
18#include <linux/key-type.h> 18#include <linux/key-type.h>
19#include <linux/crypto.h> 19#include <linux/crypto.h>
20#include <linux/ctype.h>
20#include <net/sock.h> 21#include <net/sock.h>
21#include <net/af_rxrpc.h> 22#include <net/af_rxrpc.h>
22#include <keys/rxrpc-type.h> 23#include <keys/rxrpc-type.h>
@@ -28,6 +29,7 @@ static int rxrpc_instantiate_s(struct key *, const void *, size_t);
28static void rxrpc_destroy(struct key *); 29static void rxrpc_destroy(struct key *);
29static void rxrpc_destroy_s(struct key *); 30static void rxrpc_destroy_s(struct key *);
30static void rxrpc_describe(const struct key *, struct seq_file *); 31static void rxrpc_describe(const struct key *, struct seq_file *);
32static long rxrpc_read(const struct key *, char __user *, size_t);
31 33
32/* 34/*
33 * rxrpc defined keys take an arbitrary string as the description and an 35 * rxrpc defined keys take an arbitrary string as the description and an
@@ -39,6 +41,7 @@ struct key_type key_type_rxrpc = {
39 .match = user_match, 41 .match = user_match,
40 .destroy = rxrpc_destroy, 42 .destroy = rxrpc_destroy,
41 .describe = rxrpc_describe, 43 .describe = rxrpc_describe,
44 .read = rxrpc_read,
42}; 45};
43EXPORT_SYMBOL(key_type_rxrpc); 46EXPORT_SYMBOL(key_type_rxrpc);
44 47
@@ -55,6 +58,595 @@ struct key_type key_type_rxrpc_s = {
55}; 58};
56 59
57/* 60/*
61 * parse an RxKAD type XDR format token
62 * - the caller guarantees we have at least 4 words
63 */
64static int rxrpc_instantiate_xdr_rxkad(struct key *key, const __be32 *xdr,
65 unsigned toklen)
66{
67 struct rxrpc_key_token *token, **pptoken;
68 size_t plen;
69 u32 tktlen;
70 int ret;
71
72 _enter(",{%x,%x,%x,%x},%u",
73 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]),
74 toklen);
75
76 if (toklen <= 8 * 4)
77 return -EKEYREJECTED;
78 tktlen = ntohl(xdr[7]);
79 _debug("tktlen: %x", tktlen);
80 if (tktlen > AFSTOKEN_RK_TIX_MAX)
81 return -EKEYREJECTED;
82 if (8 * 4 + tktlen != toklen)
83 return -EKEYREJECTED;
84
85 plen = sizeof(*token) + sizeof(*token->kad) + tktlen;
86 ret = key_payload_reserve(key, key->datalen + plen);
87 if (ret < 0)
88 return ret;
89
90 plen -= sizeof(*token);
91 token = kmalloc(sizeof(*token), GFP_KERNEL);
92 if (!token)
93 return -ENOMEM;
94
95 token->kad = kmalloc(plen, GFP_KERNEL);
96 if (!token->kad) {
97 kfree(token);
98 return -ENOMEM;
99 }
100
101 token->security_index = RXRPC_SECURITY_RXKAD;
102 token->kad->ticket_len = tktlen;
103 token->kad->vice_id = ntohl(xdr[0]);
104 token->kad->kvno = ntohl(xdr[1]);
105 token->kad->start = ntohl(xdr[4]);
106 token->kad->expiry = ntohl(xdr[5]);
107 token->kad->primary_flag = ntohl(xdr[6]);
108 memcpy(&token->kad->session_key, &xdr[2], 8);
109 memcpy(&token->kad->ticket, &xdr[8], tktlen);
110
111 _debug("SCIX: %u", token->security_index);
112 _debug("TLEN: %u", token->kad->ticket_len);
113 _debug("EXPY: %x", token->kad->expiry);
114 _debug("KVNO: %u", token->kad->kvno);
115 _debug("PRIM: %u", token->kad->primary_flag);
116 _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x",
117 token->kad->session_key[0], token->kad->session_key[1],
118 token->kad->session_key[2], token->kad->session_key[3],
119 token->kad->session_key[4], token->kad->session_key[5],
120 token->kad->session_key[6], token->kad->session_key[7]);
121 if (token->kad->ticket_len >= 8)
122 _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x",
123 token->kad->ticket[0], token->kad->ticket[1],
124 token->kad->ticket[2], token->kad->ticket[3],
125 token->kad->ticket[4], token->kad->ticket[5],
126 token->kad->ticket[6], token->kad->ticket[7]);
127
128 /* count the number of tokens attached */
129 key->type_data.x[0]++;
130
131 /* attach the data */
132 for (pptoken = (struct rxrpc_key_token **)&key->payload.data;
133 *pptoken;
134 pptoken = &(*pptoken)->next)
135 continue;
136 *pptoken = token;
137 if (token->kad->expiry < key->expiry)
138 key->expiry = token->kad->expiry;
139
140 _leave(" = 0");
141 return 0;
142}
143
144static void rxrpc_free_krb5_principal(struct krb5_principal *princ)
145{
146 int loop;
147
148 if (princ->name_parts) {
149 for (loop = princ->n_name_parts - 1; loop >= 0; loop--)
150 kfree(princ->name_parts[loop]);
151 kfree(princ->name_parts);
152 }
153 kfree(princ->realm);
154}
155
156static void rxrpc_free_krb5_tagged(struct krb5_tagged_data *td)
157{
158 kfree(td->data);
159}
160
161/*
162 * free up an RxK5 token
163 */
164static void rxrpc_rxk5_free(struct rxk5_key *rxk5)
165{
166 int loop;
167
168 rxrpc_free_krb5_principal(&rxk5->client);
169 rxrpc_free_krb5_principal(&rxk5->server);
170 rxrpc_free_krb5_tagged(&rxk5->session);
171
172 if (rxk5->addresses) {
173 for (loop = rxk5->n_addresses - 1; loop >= 0; loop--)
174 rxrpc_free_krb5_tagged(&rxk5->addresses[loop]);
175 kfree(rxk5->addresses);
176 }
177 if (rxk5->authdata) {
178 for (loop = rxk5->n_authdata - 1; loop >= 0; loop--)
179 rxrpc_free_krb5_tagged(&rxk5->authdata[loop]);
180 kfree(rxk5->authdata);
181 }
182
183 kfree(rxk5->ticket);
184 kfree(rxk5->ticket2);
185 kfree(rxk5);
186}
187
188/*
189 * extract a krb5 principal
190 */
191static int rxrpc_krb5_decode_principal(struct krb5_principal *princ,
192 const __be32 **_xdr,
193 unsigned *_toklen)
194{
195 const __be32 *xdr = *_xdr;
196 unsigned toklen = *_toklen, n_parts, loop, tmp;
197
198 /* there must be at least one name, and at least #names+1 length
199 * words */
200 if (toklen <= 12)
201 return -EINVAL;
202
203 _enter(",{%x,%x,%x},%u",
204 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), toklen);
205
206 n_parts = ntohl(*xdr++);
207 toklen -= 4;
208 if (n_parts <= 0 || n_parts > AFSTOKEN_K5_COMPONENTS_MAX)
209 return -EINVAL;
210 princ->n_name_parts = n_parts;
211
212 if (toklen <= (n_parts + 1) * 4)
213 return -EINVAL;
214
215 princ->name_parts = kcalloc(sizeof(char *), n_parts, GFP_KERNEL);
216 if (!princ->name_parts)
217 return -ENOMEM;
218
219 for (loop = 0; loop < n_parts; loop++) {
220 if (toklen < 4)
221 return -EINVAL;
222 tmp = ntohl(*xdr++);
223 toklen -= 4;
224 if (tmp <= 0 || tmp > AFSTOKEN_STRING_MAX)
225 return -EINVAL;
226 if (tmp > toklen)
227 return -EINVAL;
228 princ->name_parts[loop] = kmalloc(tmp + 1, GFP_KERNEL);
229 if (!princ->name_parts[loop])
230 return -ENOMEM;
231 memcpy(princ->name_parts[loop], xdr, tmp);
232 princ->name_parts[loop][tmp] = 0;
233 tmp = (tmp + 3) & ~3;
234 toklen -= tmp;
235 xdr += tmp >> 2;
236 }
237
238 if (toklen < 4)
239 return -EINVAL;
240 tmp = ntohl(*xdr++);
241 toklen -= 4;
242 if (tmp <= 0 || tmp > AFSTOKEN_K5_REALM_MAX)
243 return -EINVAL;
244 if (tmp > toklen)
245 return -EINVAL;
246 princ->realm = kmalloc(tmp + 1, GFP_KERNEL);
247 if (!princ->realm)
248 return -ENOMEM;
249 memcpy(princ->realm, xdr, tmp);
250 princ->realm[tmp] = 0;
251 tmp = (tmp + 3) & ~3;
252 toklen -= tmp;
253 xdr += tmp >> 2;
254
255 _debug("%s/...@%s", princ->name_parts[0], princ->realm);
256
257 *_xdr = xdr;
258 *_toklen = toklen;
259 _leave(" = 0 [toklen=%u]", toklen);
260 return 0;
261}
262
263/*
264 * extract a piece of krb5 tagged data
265 */
266static int rxrpc_krb5_decode_tagged_data(struct krb5_tagged_data *td,
267 size_t max_data_size,
268 const __be32 **_xdr,
269 unsigned *_toklen)
270{
271 const __be32 *xdr = *_xdr;
272 unsigned toklen = *_toklen, len;
273
274 /* there must be at least one tag and one length word */
275 if (toklen <= 8)
276 return -EINVAL;
277
278 _enter(",%zu,{%x,%x},%u",
279 max_data_size, ntohl(xdr[0]), ntohl(xdr[1]), toklen);
280
281 td->tag = ntohl(*xdr++);
282 len = ntohl(*xdr++);
283 toklen -= 8;
284 if (len > max_data_size)
285 return -EINVAL;
286 td->data_len = len;
287
288 if (len > 0) {
289 td->data = kmalloc(len, GFP_KERNEL);
290 if (!td->data)
291 return -ENOMEM;
292 memcpy(td->data, xdr, len);
293 len = (len + 3) & ~3;
294 toklen -= len;
295 xdr += len >> 2;
296 }
297
298 _debug("tag %x len %x", td->tag, td->data_len);
299
300 *_xdr = xdr;
301 *_toklen = toklen;
302 _leave(" = 0 [toklen=%u]", toklen);
303 return 0;
304}
305
306/*
307 * extract an array of tagged data
308 */
309static int rxrpc_krb5_decode_tagged_array(struct krb5_tagged_data **_td,
310 u8 *_n_elem,
311 u8 max_n_elem,
312 size_t max_elem_size,
313 const __be32 **_xdr,
314 unsigned *_toklen)
315{
316 struct krb5_tagged_data *td;
317 const __be32 *xdr = *_xdr;
318 unsigned toklen = *_toklen, n_elem, loop;
319 int ret;
320
321 /* there must be at least one count */
322 if (toklen < 4)
323 return -EINVAL;
324
325 _enter(",,%u,%zu,{%x},%u",
326 max_n_elem, max_elem_size, ntohl(xdr[0]), toklen);
327
328 n_elem = ntohl(*xdr++);
329 toklen -= 4;
330 if (n_elem < 0 || n_elem > max_n_elem)
331 return -EINVAL;
332 *_n_elem = n_elem;
333 if (n_elem > 0) {
334 if (toklen <= (n_elem + 1) * 4)
335 return -EINVAL;
336
337 _debug("n_elem %d", n_elem);
338
339 td = kcalloc(sizeof(struct krb5_tagged_data), n_elem,
340 GFP_KERNEL);
341 if (!td)
342 return -ENOMEM;
343 *_td = td;
344
345 for (loop = 0; loop < n_elem; loop++) {
346 ret = rxrpc_krb5_decode_tagged_data(&td[loop],
347 max_elem_size,
348 &xdr, &toklen);
349 if (ret < 0)
350 return ret;
351 }
352 }
353
354 *_xdr = xdr;
355 *_toklen = toklen;
356 _leave(" = 0 [toklen=%u]", toklen);
357 return 0;
358}
359
360/*
361 * extract a krb5 ticket
362 */
363static int rxrpc_krb5_decode_ticket(u8 **_ticket, u16 *_tktlen,
364 const __be32 **_xdr, unsigned *_toklen)
365{
366 const __be32 *xdr = *_xdr;
367 unsigned toklen = *_toklen, len;
368
369 /* there must be at least one length word */
370 if (toklen <= 4)
371 return -EINVAL;
372
373 _enter(",{%x},%u", ntohl(xdr[0]), toklen);
374
375 len = ntohl(*xdr++);
376 toklen -= 4;
377 if (len > AFSTOKEN_K5_TIX_MAX)
378 return -EINVAL;
379 *_tktlen = len;
380
381 _debug("ticket len %u", len);
382
383 if (len > 0) {
384 *_ticket = kmalloc(len, GFP_KERNEL);
385 if (!*_ticket)
386 return -ENOMEM;
387 memcpy(*_ticket, xdr, len);
388 len = (len + 3) & ~3;
389 toklen -= len;
390 xdr += len >> 2;
391 }
392
393 *_xdr = xdr;
394 *_toklen = toklen;
395 _leave(" = 0 [toklen=%u]", toklen);
396 return 0;
397}
398
399/*
400 * parse an RxK5 type XDR format token
401 * - the caller guarantees we have at least 4 words
402 */
403static int rxrpc_instantiate_xdr_rxk5(struct key *key, const __be32 *xdr,
404 unsigned toklen)
405{
406 struct rxrpc_key_token *token, **pptoken;
407 struct rxk5_key *rxk5;
408 const __be32 *end_xdr = xdr + (toklen >> 2);
409 int ret;
410
411 _enter(",{%x,%x,%x,%x},%u",
412 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]),
413 toklen);
414
415 /* reserve some payload space for this subkey - the length of the token
416 * is a reasonable approximation */
417 ret = key_payload_reserve(key, key->datalen + toklen);
418 if (ret < 0)
419 return ret;
420
421 token = kzalloc(sizeof(*token), GFP_KERNEL);
422 if (!token)
423 return -ENOMEM;
424
425 rxk5 = kzalloc(sizeof(*rxk5), GFP_KERNEL);
426 if (!rxk5) {
427 kfree(token);
428 return -ENOMEM;
429 }
430
431 token->security_index = RXRPC_SECURITY_RXK5;
432 token->k5 = rxk5;
433
434 /* extract the principals */
435 ret = rxrpc_krb5_decode_principal(&rxk5->client, &xdr, &toklen);
436 if (ret < 0)
437 goto error;
438 ret = rxrpc_krb5_decode_principal(&rxk5->server, &xdr, &toklen);
439 if (ret < 0)
440 goto error;
441
442 /* extract the session key and the encoding type (the tag field ->
443 * ENCTYPE_xxx) */
444 ret = rxrpc_krb5_decode_tagged_data(&rxk5->session, AFSTOKEN_DATA_MAX,
445 &xdr, &toklen);
446 if (ret < 0)
447 goto error;
448
449 if (toklen < 4 * 8 + 2 * 4)
450 goto inval;
451 rxk5->authtime = be64_to_cpup((const __be64 *) xdr);
452 xdr += 2;
453 rxk5->starttime = be64_to_cpup((const __be64 *) xdr);
454 xdr += 2;
455 rxk5->endtime = be64_to_cpup((const __be64 *) xdr);
456 xdr += 2;
457 rxk5->renew_till = be64_to_cpup((const __be64 *) xdr);
458 xdr += 2;
459 rxk5->is_skey = ntohl(*xdr++);
460 rxk5->flags = ntohl(*xdr++);
461 toklen -= 4 * 8 + 2 * 4;
462
463 _debug("times: a=%llx s=%llx e=%llx rt=%llx",
464 rxk5->authtime, rxk5->starttime, rxk5->endtime,
465 rxk5->renew_till);
466 _debug("is_skey=%x flags=%x", rxk5->is_skey, rxk5->flags);
467
468 /* extract the permitted client addresses */
469 ret = rxrpc_krb5_decode_tagged_array(&rxk5->addresses,
470 &rxk5->n_addresses,
471 AFSTOKEN_K5_ADDRESSES_MAX,
472 AFSTOKEN_DATA_MAX,
473 &xdr, &toklen);
474 if (ret < 0)
475 goto error;
476
477 ASSERTCMP((end_xdr - xdr) << 2, ==, toklen);
478
479 /* extract the tickets */
480 ret = rxrpc_krb5_decode_ticket(&rxk5->ticket, &rxk5->ticket_len,
481 &xdr, &toklen);
482 if (ret < 0)
483 goto error;
484 ret = rxrpc_krb5_decode_ticket(&rxk5->ticket2, &rxk5->ticket2_len,
485 &xdr, &toklen);
486 if (ret < 0)
487 goto error;
488
489 ASSERTCMP((end_xdr - xdr) << 2, ==, toklen);
490
491 /* extract the typed auth data */
492 ret = rxrpc_krb5_decode_tagged_array(&rxk5->authdata,
493 &rxk5->n_authdata,
494 AFSTOKEN_K5_AUTHDATA_MAX,
495 AFSTOKEN_BDATALN_MAX,
496 &xdr, &toklen);
497 if (ret < 0)
498 goto error;
499
500 ASSERTCMP((end_xdr - xdr) << 2, ==, toklen);
501
502 if (toklen != 0)
503 goto inval;
504
505 /* attach the payload to the key */
506 for (pptoken = (struct rxrpc_key_token **)&key->payload.data;
507 *pptoken;
508 pptoken = &(*pptoken)->next)
509 continue;
510 *pptoken = token;
511 if (token->kad->expiry < key->expiry)
512 key->expiry = token->kad->expiry;
513
514 _leave(" = 0");
515 return 0;
516
517inval:
518 ret = -EINVAL;
519error:
520 rxrpc_rxk5_free(rxk5);
521 kfree(token);
522 _leave(" = %d", ret);
523 return ret;
524}
525
526/*
527 * attempt to parse the data as the XDR format
528 * - the caller guarantees we have more than 7 words
529 */
530static int rxrpc_instantiate_xdr(struct key *key, const void *data, size_t datalen)
531{
532 const __be32 *xdr = data, *token;
533 const char *cp;
534 unsigned len, tmp, loop, ntoken, toklen, sec_ix;
535 int ret;
536
537 _enter(",{%x,%x,%x,%x},%zu",
538 ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]),
539 datalen);
540
541 if (datalen > AFSTOKEN_LENGTH_MAX)
542 goto not_xdr;
543
544 /* XDR is an array of __be32's */
545 if (datalen & 3)
546 goto not_xdr;
547
548 /* the flags should be 0 (the setpag bit must be handled by
549 * userspace) */
550 if (ntohl(*xdr++) != 0)
551 goto not_xdr;
552 datalen -= 4;
553
554 /* check the cell name */
555 len = ntohl(*xdr++);
556 if (len < 1 || len > AFSTOKEN_CELL_MAX)
557 goto not_xdr;
558 datalen -= 4;
559 tmp = (len + 3) & ~3;
560 if (tmp > datalen)
561 goto not_xdr;
562
563 cp = (const char *) xdr;
564 for (loop = 0; loop < len; loop++)
565 if (!isprint(cp[loop]))
566 goto not_xdr;
567 if (len < tmp)
568 for (; loop < tmp; loop++)
569 if (cp[loop])
570 goto not_xdr;
571 _debug("cellname: [%u/%u] '%*.*s'",
572 len, tmp, len, len, (const char *) xdr);
573 datalen -= tmp;
574 xdr += tmp >> 2;
575
576 /* get the token count */
577 if (datalen < 12)
578 goto not_xdr;
579 ntoken = ntohl(*xdr++);
580 datalen -= 4;
581 _debug("ntoken: %x", ntoken);
582 if (ntoken < 1 || ntoken > AFSTOKEN_MAX)
583 goto not_xdr;
584
585 /* check each token wrapper */
586 token = xdr;
587 loop = ntoken;
588 do {
589 if (datalen < 8)
590 goto not_xdr;
591 toklen = ntohl(*xdr++);
592 sec_ix = ntohl(*xdr);
593 datalen -= 4;
594 _debug("token: [%x/%zx] %x", toklen, datalen, sec_ix);
595 if (toklen < 20 || toklen > datalen)
596 goto not_xdr;
597 datalen -= (toklen + 3) & ~3;
598 xdr += (toklen + 3) >> 2;
599
600 } while (--loop > 0);
601
602 _debug("remainder: %zu", datalen);
603 if (datalen != 0)
604 goto not_xdr;
605
606 /* okay: we're going to assume it's valid XDR format
607 * - we ignore the cellname, relying on the key to be correctly named
608 */
609 do {
610 xdr = token;
611 toklen = ntohl(*xdr++);
612 token = xdr + ((toklen + 3) >> 2);
613 sec_ix = ntohl(*xdr++);
614 toklen -= 4;
615
616 _debug("TOKEN type=%u [%p-%p]", sec_ix, xdr, token);
617
618 switch (sec_ix) {
619 case RXRPC_SECURITY_RXKAD:
620 ret = rxrpc_instantiate_xdr_rxkad(key, xdr, toklen);
621 if (ret != 0)
622 goto error;
623 break;
624
625 case RXRPC_SECURITY_RXK5:
626 ret = rxrpc_instantiate_xdr_rxk5(key, xdr, toklen);
627 if (ret != 0)
628 goto error;
629 break;
630
631 default:
632 ret = -EPROTONOSUPPORT;
633 goto error;
634 }
635
636 } while (--ntoken > 0);
637
638 _leave(" = 0");
639 return 0;
640
641not_xdr:
642 _leave(" = -EPROTO");
643 return -EPROTO;
644error:
645 _leave(" = %d", ret);
646 return ret;
647}
648
649/*
58 * instantiate an rxrpc defined key 650 * instantiate an rxrpc defined key
59 * data should be of the form: 651 * data should be of the form:
60 * OFFSET LEN CONTENT 652 * OFFSET LEN CONTENT
@@ -70,8 +662,8 @@ struct key_type key_type_rxrpc_s = {
70 */ 662 */
71static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen) 663static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
72{ 664{
73 const struct rxkad_key *tsec; 665 const struct rxrpc_key_data_v1 *v1;
74 struct rxrpc_key_payload *upayload; 666 struct rxrpc_key_token *token, **pp;
75 size_t plen; 667 size_t plen;
76 u32 kver; 668 u32 kver;
77 int ret; 669 int ret;
@@ -82,6 +674,13 @@ static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
82 if (!data && datalen == 0) 674 if (!data && datalen == 0)
83 return 0; 675 return 0;
84 676
677 /* determine if the XDR payload format is being used */
678 if (datalen > 7 * 4) {
679 ret = rxrpc_instantiate_xdr(key, data, datalen);
680 if (ret != -EPROTO)
681 return ret;
682 }
683
85 /* get the key interface version number */ 684 /* get the key interface version number */
86 ret = -EINVAL; 685 ret = -EINVAL;
87 if (datalen <= 4 || !data) 686 if (datalen <= 4 || !data)
@@ -98,53 +697,67 @@ static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen)
98 697
99 /* deal with a version 1 key */ 698 /* deal with a version 1 key */
100 ret = -EINVAL; 699 ret = -EINVAL;
101 if (datalen < sizeof(*tsec)) 700 if (datalen < sizeof(*v1))
102 goto error; 701 goto error;
103 702
104 tsec = data; 703 v1 = data;
105 if (datalen != sizeof(*tsec) + tsec->ticket_len) 704 if (datalen != sizeof(*v1) + v1->ticket_length)
106 goto error; 705 goto error;
107 706
108 _debug("SCIX: %u", tsec->security_index); 707 _debug("SCIX: %u", v1->security_index);
109 _debug("TLEN: %u", tsec->ticket_len); 708 _debug("TLEN: %u", v1->ticket_length);
110 _debug("EXPY: %x", tsec->expiry); 709 _debug("EXPY: %x", v1->expiry);
111 _debug("KVNO: %u", tsec->kvno); 710 _debug("KVNO: %u", v1->kvno);
112 _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x", 711 _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x",
113 tsec->session_key[0], tsec->session_key[1], 712 v1->session_key[0], v1->session_key[1],
114 tsec->session_key[2], tsec->session_key[3], 713 v1->session_key[2], v1->session_key[3],
115 tsec->session_key[4], tsec->session_key[5], 714 v1->session_key[4], v1->session_key[5],
116 tsec->session_key[6], tsec->session_key[7]); 715 v1->session_key[6], v1->session_key[7]);
117 if (tsec->ticket_len >= 8) 716 if (v1->ticket_length >= 8)
118 _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x", 717 _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x",
119 tsec->ticket[0], tsec->ticket[1], 718 v1->ticket[0], v1->ticket[1],
120 tsec->ticket[2], tsec->ticket[3], 719 v1->ticket[2], v1->ticket[3],
121 tsec->ticket[4], tsec->ticket[5], 720 v1->ticket[4], v1->ticket[5],
122 tsec->ticket[6], tsec->ticket[7]); 721 v1->ticket[6], v1->ticket[7]);
123 722
124 ret = -EPROTONOSUPPORT; 723 ret = -EPROTONOSUPPORT;
125 if (tsec->security_index != 2) 724 if (v1->security_index != RXRPC_SECURITY_RXKAD)
126 goto error; 725 goto error;
127 726
128 key->type_data.x[0] = tsec->security_index; 727 plen = sizeof(*token->kad) + v1->ticket_length;
129 728 ret = key_payload_reserve(key, plen + sizeof(*token));
130 plen = sizeof(*upayload) + tsec->ticket_len;
131 ret = key_payload_reserve(key, plen);
132 if (ret < 0) 729 if (ret < 0)
133 goto error; 730 goto error;
134 731
135 ret = -ENOMEM; 732 ret = -ENOMEM;
136 upayload = kmalloc(plen, GFP_KERNEL); 733 token = kmalloc(sizeof(*token), GFP_KERNEL);
137 if (!upayload) 734 if (!token)
138 goto error; 735 goto error;
736 token->kad = kmalloc(plen, GFP_KERNEL);
737 if (!token->kad)
738 goto error_free;
739
740 token->security_index = RXRPC_SECURITY_RXKAD;
741 token->kad->ticket_len = v1->ticket_length;
742 token->kad->expiry = v1->expiry;
743 token->kad->kvno = v1->kvno;
744 memcpy(&token->kad->session_key, &v1->session_key, 8);
745 memcpy(&token->kad->ticket, v1->ticket, v1->ticket_length);
139 746
140 /* attach the data */ 747 /* attach the data */
141 memcpy(&upayload->k, tsec, sizeof(*tsec)); 748 key->type_data.x[0]++;
142 memcpy(&upayload->k.ticket, (void *)tsec + sizeof(*tsec), 749
143 tsec->ticket_len); 750 pp = (struct rxrpc_key_token **)&key->payload.data;
144 key->payload.data = upayload; 751 while (*pp)
145 key->expiry = tsec->expiry; 752 pp = &(*pp)->next;
753 *pp = token;
754 if (token->kad->expiry < key->expiry)
755 key->expiry = token->kad->expiry;
756 token = NULL;
146 ret = 0; 757 ret = 0;
147 758
759error_free:
760 kfree(token);
148error: 761error:
149 return ret; 762 return ret;
150} 763}
@@ -184,7 +797,26 @@ static int rxrpc_instantiate_s(struct key *key, const void *data,
184 */ 797 */
185static void rxrpc_destroy(struct key *key) 798static void rxrpc_destroy(struct key *key)
186{ 799{
187 kfree(key->payload.data); 800 struct rxrpc_key_token *token;
801
802 while ((token = key->payload.data)) {
803 key->payload.data = token->next;
804 switch (token->security_index) {
805 case RXRPC_SECURITY_RXKAD:
806 kfree(token->kad);
807 break;
808 case RXRPC_SECURITY_RXK5:
809 if (token->k5)
810 rxrpc_rxk5_free(token->k5);
811 break;
812 default:
813 printk(KERN_ERR "Unknown token type %x on rxrpc key\n",
814 token->security_index);
815 BUG();
816 }
817
818 kfree(token);
819 }
188} 820}
189 821
190/* 822/*
@@ -293,7 +925,7 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn,
293 925
294 struct { 926 struct {
295 u32 kver; 927 u32 kver;
296 struct rxkad_key tsec; 928 struct rxrpc_key_data_v1 v1;
297 } data; 929 } data;
298 930
299 _enter(""); 931 _enter("");
@@ -308,13 +940,12 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn,
308 _debug("key %d", key_serial(key)); 940 _debug("key %d", key_serial(key));
309 941
310 data.kver = 1; 942 data.kver = 1;
311 data.tsec.security_index = 2; 943 data.v1.security_index = RXRPC_SECURITY_RXKAD;
312 data.tsec.ticket_len = 0; 944 data.v1.ticket_length = 0;
313 data.tsec.expiry = expiry; 945 data.v1.expiry = expiry;
314 data.tsec.kvno = 0; 946 data.v1.kvno = 0;
315 947
316 memcpy(&data.tsec.session_key, session_key, 948 memcpy(&data.v1.session_key, session_key, sizeof(data.v1.session_key));
317 sizeof(data.tsec.session_key));
318 949
319 ret = key_instantiate_and_link(key, &data, sizeof(data), NULL, NULL); 950 ret = key_instantiate_and_link(key, &data, sizeof(data), NULL, NULL);
320 if (ret < 0) 951 if (ret < 0)
@@ -360,3 +991,210 @@ struct key *rxrpc_get_null_key(const char *keyname)
360 return key; 991 return key;
361} 992}
362EXPORT_SYMBOL(rxrpc_get_null_key); 993EXPORT_SYMBOL(rxrpc_get_null_key);
994
995/*
996 * read the contents of an rxrpc key
997 * - this returns the result in XDR form
998 */
999static long rxrpc_read(const struct key *key,
1000 char __user *buffer, size_t buflen)
1001{
1002 const struct rxrpc_key_token *token;
1003 const struct krb5_principal *princ;
1004 size_t size;
1005 __be32 __user *xdr, *oldxdr;
1006 u32 cnlen, toksize, ntoks, tok, zero;
1007 u16 toksizes[AFSTOKEN_MAX];
1008 int loop;
1009
1010 _enter("");
1011
1012 /* we don't know what form we should return non-AFS keys in */
1013 if (memcmp(key->description, "afs@", 4) != 0)
1014 return -EOPNOTSUPP;
1015 cnlen = strlen(key->description + 4);
1016
1017#define RND(X) (((X) + 3) & ~3)
1018
1019 /* AFS keys we return in XDR form, so we need to work out the size of
1020 * the XDR */
1021 size = 2 * 4; /* flags, cellname len */
1022 size += RND(cnlen); /* cellname */
1023 size += 1 * 4; /* token count */
1024
1025 ntoks = 0;
1026 for (token = key->payload.data; token; token = token->next) {
1027 toksize = 4; /* sec index */
1028
1029 switch (token->security_index) {
1030 case RXRPC_SECURITY_RXKAD:
1031 toksize += 8 * 4; /* viceid, kvno, key*2, begin,
1032 * end, primary, tktlen */
1033 toksize += RND(token->kad->ticket_len);
1034 break;
1035
1036 case RXRPC_SECURITY_RXK5:
1037 princ = &token->k5->client;
1038 toksize += 4 + princ->n_name_parts * 4;
1039 for (loop = 0; loop < princ->n_name_parts; loop++)
1040 toksize += RND(strlen(princ->name_parts[loop]));
1041 toksize += 4 + RND(strlen(princ->realm));
1042
1043 princ = &token->k5->server;
1044 toksize += 4 + princ->n_name_parts * 4;
1045 for (loop = 0; loop < princ->n_name_parts; loop++)
1046 toksize += RND(strlen(princ->name_parts[loop]));
1047 toksize += 4 + RND(strlen(princ->realm));
1048
1049 toksize += 8 + RND(token->k5->session.data_len);
1050
1051 toksize += 4 * 8 + 2 * 4;
1052
1053 toksize += 4 + token->k5->n_addresses * 8;
1054 for (loop = 0; loop < token->k5->n_addresses; loop++)
1055 toksize += RND(token->k5->addresses[loop].data_len);
1056
1057 toksize += 4 + RND(token->k5->ticket_len);
1058 toksize += 4 + RND(token->k5->ticket2_len);
1059
1060 toksize += 4 + token->k5->n_authdata * 8;
1061 for (loop = 0; loop < token->k5->n_authdata; loop++)
1062 toksize += RND(token->k5->authdata[loop].data_len);
1063 break;
1064
1065 default: /* we have a ticket we can't encode */
1066 BUG();
1067 continue;
1068 }
1069
1070 _debug("token[%u]: toksize=%u", ntoks, toksize);
1071 ASSERTCMP(toksize, <=, AFSTOKEN_LENGTH_MAX);
1072
1073 toksizes[ntoks++] = toksize;
1074 size += toksize + 4; /* each token has a length word */
1075 }
1076
1077#undef RND
1078
1079 if (!buffer || buflen < size)
1080 return size;
1081
1082 xdr = (__be32 __user *) buffer;
1083 zero = 0;
1084#define ENCODE(x) \
1085 do { \
1086 __be32 y = htonl(x); \
1087 if (put_user(y, xdr++) < 0) \
1088 goto fault; \
1089 } while(0)
1090#define ENCODE_DATA(l, s) \
1091 do { \
1092 u32 _l = (l); \
1093 ENCODE(l); \
1094 if (copy_to_user(xdr, (s), _l) != 0) \
1095 goto fault; \
1096 if (_l & 3 && \
1097 copy_to_user((u8 *)xdr + _l, &zero, 4 - (_l & 3)) != 0) \
1098 goto fault; \
1099 xdr += (_l + 3) >> 2; \
1100 } while(0)
1101#define ENCODE64(x) \
1102 do { \
1103 __be64 y = cpu_to_be64(x); \
1104 if (copy_to_user(xdr, &y, 8) != 0) \
1105 goto fault; \
1106 xdr += 8 >> 2; \
1107 } while(0)
1108#define ENCODE_STR(s) \
1109 do { \
1110 const char *_s = (s); \
1111 ENCODE_DATA(strlen(_s), _s); \
1112 } while(0)
1113
1114 ENCODE(0); /* flags */
1115 ENCODE_DATA(cnlen, key->description + 4); /* cellname */
1116 ENCODE(ntoks);
1117
1118 tok = 0;
1119 for (token = key->payload.data; token; token = token->next) {
1120 toksize = toksizes[tok++];
1121 ENCODE(toksize);
1122 oldxdr = xdr;
1123 ENCODE(token->security_index);
1124
1125 switch (token->security_index) {
1126 case RXRPC_SECURITY_RXKAD:
1127 ENCODE(token->kad->vice_id);
1128 ENCODE(token->kad->kvno);
1129 ENCODE_DATA(8, token->kad->session_key);
1130 ENCODE(token->kad->start);
1131 ENCODE(token->kad->expiry);
1132 ENCODE(token->kad->primary_flag);
1133 ENCODE_DATA(token->kad->ticket_len, token->kad->ticket);
1134 break;
1135
1136 case RXRPC_SECURITY_RXK5:
1137 princ = &token->k5->client;
1138 ENCODE(princ->n_name_parts);
1139 for (loop = 0; loop < princ->n_name_parts; loop++)
1140 ENCODE_STR(princ->name_parts[loop]);
1141 ENCODE_STR(princ->realm);
1142
1143 princ = &token->k5->server;
1144 ENCODE(princ->n_name_parts);
1145 for (loop = 0; loop < princ->n_name_parts; loop++)
1146 ENCODE_STR(princ->name_parts[loop]);
1147 ENCODE_STR(princ->realm);
1148
1149 ENCODE(token->k5->session.tag);
1150 ENCODE_DATA(token->k5->session.data_len,
1151 token->k5->session.data);
1152
1153 ENCODE64(token->k5->authtime);
1154 ENCODE64(token->k5->starttime);
1155 ENCODE64(token->k5->endtime);
1156 ENCODE64(token->k5->renew_till);
1157 ENCODE(token->k5->is_skey);
1158 ENCODE(token->k5->flags);
1159
1160 ENCODE(token->k5->n_addresses);
1161 for (loop = 0; loop < token->k5->n_addresses; loop++) {
1162 ENCODE(token->k5->addresses[loop].tag);
1163 ENCODE_DATA(token->k5->addresses[loop].data_len,
1164 token->k5->addresses[loop].data);
1165 }
1166
1167 ENCODE_DATA(token->k5->ticket_len, token->k5->ticket);
1168 ENCODE_DATA(token->k5->ticket2_len, token->k5->ticket2);
1169
1170 ENCODE(token->k5->n_authdata);
1171 for (loop = 0; loop < token->k5->n_authdata; loop++) {
1172 ENCODE(token->k5->authdata[loop].tag);
1173 ENCODE_DATA(token->k5->authdata[loop].data_len,
1174 token->k5->authdata[loop].data);
1175 }
1176 break;
1177
1178 default:
1179 BUG();
1180 break;
1181 }
1182
1183 ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, ==,
1184 toksize);
1185 }
1186
1187#undef ENCODE_STR
1188#undef ENCODE_DATA
1189#undef ENCODE64
1190#undef ENCODE
1191
1192 ASSERTCMP(tok, ==, ntoks);
1193 ASSERTCMP((char __user *) xdr - buffer, ==, size);
1194 _leave(" = %zu", size);
1195 return size;
1196
1197fault:
1198 _leave(" = -EFAULT");
1199 return -EFAULT;
1200}
diff --git a/net/rxrpc/ar-security.c b/net/rxrpc/ar-security.c
index dc62920ee19a..49b3cc31ee1f 100644
--- a/net/rxrpc/ar-security.c
+++ b/net/rxrpc/ar-security.c
@@ -16,6 +16,7 @@
16#include <linux/crypto.h> 16#include <linux/crypto.h>
17#include <net/sock.h> 17#include <net/sock.h>
18#include <net/af_rxrpc.h> 18#include <net/af_rxrpc.h>
19#include <keys/rxrpc-type.h>
19#include "ar-internal.h" 20#include "ar-internal.h"
20 21
21static LIST_HEAD(rxrpc_security_methods); 22static LIST_HEAD(rxrpc_security_methods);
@@ -122,6 +123,7 @@ EXPORT_SYMBOL_GPL(rxrpc_unregister_security);
122 */ 123 */
123int rxrpc_init_client_conn_security(struct rxrpc_connection *conn) 124int rxrpc_init_client_conn_security(struct rxrpc_connection *conn)
124{ 125{
126 struct rxrpc_key_token *token;
125 struct rxrpc_security *sec; 127 struct rxrpc_security *sec;
126 struct key *key = conn->key; 128 struct key *key = conn->key;
127 int ret; 129 int ret;
@@ -135,7 +137,11 @@ int rxrpc_init_client_conn_security(struct rxrpc_connection *conn)
135 if (ret < 0) 137 if (ret < 0)
136 return ret; 138 return ret;
137 139
138 sec = rxrpc_security_lookup(key->type_data.x[0]); 140 if (!key->payload.data)
141 return -EKEYREJECTED;
142 token = key->payload.data;
143
144 sec = rxrpc_security_lookup(token->security_index);
139 if (!sec) 145 if (!sec)
140 return -EKEYREJECTED; 146 return -EKEYREJECTED;
141 conn->security = sec; 147 conn->security = sec;
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index ef8f91030a15..713ac593e2e9 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -18,6 +18,7 @@
18#include <linux/ctype.h> 18#include <linux/ctype.h>
19#include <net/sock.h> 19#include <net/sock.h>
20#include <net/af_rxrpc.h> 20#include <net/af_rxrpc.h>
21#include <keys/rxrpc-type.h>
21#define rxrpc_debug rxkad_debug 22#define rxrpc_debug rxkad_debug
22#include "ar-internal.h" 23#include "ar-internal.h"
23 24
@@ -42,7 +43,7 @@ struct rxkad_level2_hdr {
42 __be32 checksum; /* decrypted data checksum */ 43 __be32 checksum; /* decrypted data checksum */
43}; 44};
44 45
45MODULE_DESCRIPTION("RxRPC network protocol type-2 security (Kerberos)"); 46MODULE_DESCRIPTION("RxRPC network protocol type-2 security (Kerberos 4)");
46MODULE_AUTHOR("Red Hat, Inc."); 47MODULE_AUTHOR("Red Hat, Inc.");
47MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
48 49
@@ -59,14 +60,14 @@ static DEFINE_MUTEX(rxkad_ci_mutex);
59 */ 60 */
60static int rxkad_init_connection_security(struct rxrpc_connection *conn) 61static int rxkad_init_connection_security(struct rxrpc_connection *conn)
61{ 62{
62 struct rxrpc_key_payload *payload;
63 struct crypto_blkcipher *ci; 63 struct crypto_blkcipher *ci;
64 struct rxrpc_key_token *token;
64 int ret; 65 int ret;
65 66
66 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->key)); 67 _enter("{%d},{%x}", conn->debug_id, key_serial(conn->key));
67 68
68 payload = conn->key->payload.data; 69 token = conn->key->payload.data;
69 conn->security_ix = payload->k.security_index; 70 conn->security_ix = token->security_index;
70 71
71 ci = crypto_alloc_blkcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC); 72 ci = crypto_alloc_blkcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC);
72 if (IS_ERR(ci)) { 73 if (IS_ERR(ci)) {
@@ -75,8 +76,8 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn)
75 goto error; 76 goto error;
76 } 77 }
77 78
78 if (crypto_blkcipher_setkey(ci, payload->k.session_key, 79 if (crypto_blkcipher_setkey(ci, token->kad->session_key,
79 sizeof(payload->k.session_key)) < 0) 80 sizeof(token->kad->session_key)) < 0)
80 BUG(); 81 BUG();
81 82
82 switch (conn->security_level) { 83 switch (conn->security_level) {
@@ -110,7 +111,7 @@ error:
110 */ 111 */
111static void rxkad_prime_packet_security(struct rxrpc_connection *conn) 112static void rxkad_prime_packet_security(struct rxrpc_connection *conn)
112{ 113{
113 struct rxrpc_key_payload *payload; 114 struct rxrpc_key_token *token;
114 struct blkcipher_desc desc; 115 struct blkcipher_desc desc;
115 struct scatterlist sg[2]; 116 struct scatterlist sg[2];
116 struct rxrpc_crypt iv; 117 struct rxrpc_crypt iv;
@@ -123,8 +124,8 @@ static void rxkad_prime_packet_security(struct rxrpc_connection *conn)
123 if (!conn->key) 124 if (!conn->key)
124 return; 125 return;
125 126
126 payload = conn->key->payload.data; 127 token = conn->key->payload.data;
127 memcpy(&iv, payload->k.session_key, sizeof(iv)); 128 memcpy(&iv, token->kad->session_key, sizeof(iv));
128 129
129 desc.tfm = conn->cipher; 130 desc.tfm = conn->cipher;
130 desc.info = iv.x; 131 desc.info = iv.x;
@@ -197,7 +198,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,
197 u32 data_size, 198 u32 data_size,
198 void *sechdr) 199 void *sechdr)
199{ 200{
200 const struct rxrpc_key_payload *payload; 201 const struct rxrpc_key_token *token;
201 struct rxkad_level2_hdr rxkhdr 202 struct rxkad_level2_hdr rxkhdr
202 __attribute__((aligned(8))); /* must be all on one page */ 203 __attribute__((aligned(8))); /* must be all on one page */
203 struct rxrpc_skb_priv *sp; 204 struct rxrpc_skb_priv *sp;
@@ -219,8 +220,8 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call,
219 rxkhdr.checksum = 0; 220 rxkhdr.checksum = 0;
220 221
221 /* encrypt from the session key */ 222 /* encrypt from the session key */
222 payload = call->conn->key->payload.data; 223 token = call->conn->key->payload.data;
223 memcpy(&iv, payload->k.session_key, sizeof(iv)); 224 memcpy(&iv, token->kad->session_key, sizeof(iv));
224 desc.tfm = call->conn->cipher; 225 desc.tfm = call->conn->cipher;
225 desc.info = iv.x; 226 desc.info = iv.x;
226 desc.flags = 0; 227 desc.flags = 0;
@@ -400,7 +401,7 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call,
400 struct sk_buff *skb, 401 struct sk_buff *skb,
401 u32 *_abort_code) 402 u32 *_abort_code)
402{ 403{
403 const struct rxrpc_key_payload *payload; 404 const struct rxrpc_key_token *token;
404 struct rxkad_level2_hdr sechdr; 405 struct rxkad_level2_hdr sechdr;
405 struct rxrpc_skb_priv *sp; 406 struct rxrpc_skb_priv *sp;
406 struct blkcipher_desc desc; 407 struct blkcipher_desc desc;
@@ -431,8 +432,8 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call,
431 skb_to_sgvec(skb, sg, 0, skb->len); 432 skb_to_sgvec(skb, sg, 0, skb->len);
432 433
433 /* decrypt from the session key */ 434 /* decrypt from the session key */
434 payload = call->conn->key->payload.data; 435 token = call->conn->key->payload.data;
435 memcpy(&iv, payload->k.session_key, sizeof(iv)); 436 memcpy(&iv, token->kad->session_key, sizeof(iv));
436 desc.tfm = call->conn->cipher; 437 desc.tfm = call->conn->cipher;
437 desc.info = iv.x; 438 desc.info = iv.x;
438 desc.flags = 0; 439 desc.flags = 0;
@@ -506,7 +507,7 @@ static int rxkad_verify_packet(const struct rxrpc_call *call,
506 if (!call->conn->cipher) 507 if (!call->conn->cipher)
507 return 0; 508 return 0;
508 509
509 if (sp->hdr.securityIndex != 2) { 510 if (sp->hdr.securityIndex != RXRPC_SECURITY_RXKAD) {
510 *_abort_code = RXKADINCONSISTENCY; 511 *_abort_code = RXKADINCONSISTENCY;
511 _leave(" = -EPROTO [not rxkad]"); 512 _leave(" = -EPROTO [not rxkad]");
512 return -EPROTO; 513 return -EPROTO;
@@ -737,7 +738,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
737 struct sk_buff *skb, 738 struct sk_buff *skb,
738 u32 *_abort_code) 739 u32 *_abort_code)
739{ 740{
740 const struct rxrpc_key_payload *payload; 741 const struct rxrpc_key_token *token;
741 struct rxkad_challenge challenge; 742 struct rxkad_challenge challenge;
742 struct rxkad_response resp 743 struct rxkad_response resp
743 __attribute__((aligned(8))); /* must be aligned for crypto */ 744 __attribute__((aligned(8))); /* must be aligned for crypto */
@@ -778,7 +779,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
778 if (conn->security_level < min_level) 779 if (conn->security_level < min_level)
779 goto protocol_error; 780 goto protocol_error;
780 781
781 payload = conn->key->payload.data; 782 token = conn->key->payload.data;
782 783
783 /* build the response packet */ 784 /* build the response packet */
784 memset(&resp, 0, sizeof(resp)); 785 memset(&resp, 0, sizeof(resp));
@@ -797,13 +798,13 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn,
797 (conn->channels[3] ? conn->channels[3]->call_id : 0); 798 (conn->channels[3] ? conn->channels[3]->call_id : 0);
798 resp.encrypted.inc_nonce = htonl(nonce + 1); 799 resp.encrypted.inc_nonce = htonl(nonce + 1);
799 resp.encrypted.level = htonl(conn->security_level); 800 resp.encrypted.level = htonl(conn->security_level);
800 resp.kvno = htonl(payload->k.kvno); 801 resp.kvno = htonl(token->kad->kvno);
801 resp.ticket_len = htonl(payload->k.ticket_len); 802 resp.ticket_len = htonl(token->kad->ticket_len);
802 803
803 /* calculate the response checksum and then do the encryption */ 804 /* calculate the response checksum and then do the encryption */
804 rxkad_calc_response_checksum(&resp); 805 rxkad_calc_response_checksum(&resp);
805 rxkad_encrypt_response(conn, &resp, &payload->k); 806 rxkad_encrypt_response(conn, &resp, token->kad);
806 return rxkad_send_response(conn, &sp->hdr, &resp, &payload->k); 807 return rxkad_send_response(conn, &sp->hdr, &resp, token->kad);
807 808
808protocol_error: 809protocol_error:
809 *_abort_code = abort_code; 810 *_abort_code = abort_code;
@@ -1122,7 +1123,7 @@ static void rxkad_clear(struct rxrpc_connection *conn)
1122static struct rxrpc_security rxkad = { 1123static struct rxrpc_security rxkad = {
1123 .owner = THIS_MODULE, 1124 .owner = THIS_MODULE,
1124 .name = "rxkad", 1125 .name = "rxkad",
1125 .security_index = RXKAD_VERSION, 1126 .security_index = RXRPC_SECURITY_RXKAD,
1126 .init_connection_security = rxkad_init_connection_security, 1127 .init_connection_security = rxkad_init_connection_security,
1127 .prime_packet_security = rxkad_prime_packet_security, 1128 .prime_packet_security = rxkad_prime_packet_security,
1128 .secure_packet = rxkad_secure_packet, 1129 .secure_packet = rxkad_secure_packet,
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 692d9a41cd23..903e4188b6ca 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -693,13 +693,18 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
693 if (new && i > 0) 693 if (new && i > 0)
694 atomic_inc(&new->refcnt); 694 atomic_inc(&new->refcnt);
695 695
696 qdisc_destroy(old); 696 if (!ingress)
697 qdisc_destroy(old);
697 } 698 }
698 699
699 notify_and_destroy(skb, n, classid, dev->qdisc, new); 700 if (!ingress) {
700 if (new && !new->ops->attach) 701 notify_and_destroy(skb, n, classid, dev->qdisc, new);
701 atomic_inc(&new->refcnt); 702 if (new && !new->ops->attach)
702 dev->qdisc = new ? : &noop_qdisc; 703 atomic_inc(&new->refcnt);
704 dev->qdisc = new ? : &noop_qdisc;
705 } else {
706 notify_and_destroy(skb, n, classid, old, new);
707 }
703 708
704 if (dev->flags & IFF_UP) 709 if (dev->flags & IFF_UP)
705 dev_activate(dev); 710 dev_activate(dev);
@@ -804,7 +809,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
804 stab = qdisc_get_stab(tca[TCA_STAB]); 809 stab = qdisc_get_stab(tca[TCA_STAB]);
805 if (IS_ERR(stab)) { 810 if (IS_ERR(stab)) {
806 err = PTR_ERR(stab); 811 err = PTR_ERR(stab);
807 goto err_out3; 812 goto err_out4;
808 } 813 }
809 sch->stab = stab; 814 sch->stab = stab;
810 } 815 }
@@ -833,7 +838,6 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
833 return sch; 838 return sch;
834 } 839 }
835err_out3: 840err_out3:
836 qdisc_put_stab(sch->stab);
837 dev_put(dev); 841 dev_put(dev);
838 kfree((char *) sch - sch->padded); 842 kfree((char *) sch - sch->padded);
839err_out2: 843err_out2:
@@ -847,6 +851,7 @@ err_out4:
847 * Any broken qdiscs that would require a ops->reset() here? 851 * Any broken qdiscs that would require a ops->reset() here?
848 * The qdisc was never in action so it shouldn't be necessary. 852 * The qdisc was never in action so it shouldn't be necessary.
849 */ 853 */
854 qdisc_put_stab(sch->stab);
850 if (ops->destroy) 855 if (ops->destroy)
851 ops->destroy(sch); 856 ops->destroy(sch);
852 goto err_out3; 857 goto err_out3;
@@ -1111,12 +1116,16 @@ create_n_graft:
1111 tcm->tcm_parent, tcm->tcm_parent, 1116 tcm->tcm_parent, tcm->tcm_parent,
1112 tca, &err); 1117 tca, &err);
1113 else { 1118 else {
1114 unsigned int ntx = 0; 1119 struct netdev_queue *dev_queue;
1115 1120
1116 if (p && p->ops->cl_ops && p->ops->cl_ops->select_queue) 1121 if (p && p->ops->cl_ops && p->ops->cl_ops->select_queue)
1117 ntx = p->ops->cl_ops->select_queue(p, tcm); 1122 dev_queue = p->ops->cl_ops->select_queue(p, tcm);
1123 else if (p)
1124 dev_queue = p->dev_queue;
1125 else
1126 dev_queue = netdev_get_tx_queue(dev, 0);
1118 1127
1119 q = qdisc_create(dev, netdev_get_tx_queue(dev, ntx), p, 1128 q = qdisc_create(dev, dev_queue, p,
1120 tcm->tcm_parent, tcm->tcm_handle, 1129 tcm->tcm_parent, tcm->tcm_handle,
1121 tca, &err); 1130 tca, &err);
1122 } 1131 }
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
index 12b2fb04b29b..5a888af7e5da 100644
--- a/net/sched/sch_drr.c
+++ b/net/sched/sch_drr.c
@@ -274,8 +274,10 @@ static int drr_dump_class_stats(struct Qdisc *sch, unsigned long arg,
274 struct tc_drr_stats xstats; 274 struct tc_drr_stats xstats;
275 275
276 memset(&xstats, 0, sizeof(xstats)); 276 memset(&xstats, 0, sizeof(xstats));
277 if (cl->qdisc->q.qlen) 277 if (cl->qdisc->q.qlen) {
278 xstats.deficit = cl->deficit; 278 xstats.deficit = cl->deficit;
279 cl->qdisc->qstats.qlen = cl->qdisc->q.qlen;
280 }
279 281
280 if (gnet_stats_copy_basic(d, &cl->bstats) < 0 || 282 if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
281 gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 || 283 gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 ||
diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c
index dd5ee022f1f7..d1dea3d5dc92 100644
--- a/net/sched/sch_mq.c
+++ b/net/sched/sch_mq.c
@@ -125,13 +125,18 @@ static struct netdev_queue *mq_queue_get(struct Qdisc *sch, unsigned long cl)
125 return netdev_get_tx_queue(dev, ntx); 125 return netdev_get_tx_queue(dev, ntx);
126} 126}
127 127
128static unsigned int mq_select_queue(struct Qdisc *sch, struct tcmsg *tcm) 128static struct netdev_queue *mq_select_queue(struct Qdisc *sch,
129 struct tcmsg *tcm)
129{ 130{
130 unsigned int ntx = TC_H_MIN(tcm->tcm_parent); 131 unsigned int ntx = TC_H_MIN(tcm->tcm_parent);
132 struct netdev_queue *dev_queue = mq_queue_get(sch, ntx);
131 133
132 if (!mq_queue_get(sch, ntx)) 134 if (!dev_queue) {
133 return 0; 135 struct net_device *dev = qdisc_dev(sch);
134 return ntx - 1; 136
137 return netdev_get_tx_queue(dev, 0);
138 }
139 return dev_queue;
135} 140}
136 141
137static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, 142static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new,
@@ -188,6 +193,7 @@ static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl,
188 struct netdev_queue *dev_queue = mq_queue_get(sch, cl); 193 struct netdev_queue *dev_queue = mq_queue_get(sch, cl);
189 194
190 sch = dev_queue->qdisc_sleeping; 195 sch = dev_queue->qdisc_sleeping;
196 sch->qstats.qlen = sch->q.qlen;
191 if (gnet_stats_copy_basic(d, &sch->bstats) < 0 || 197 if (gnet_stats_copy_basic(d, &sch->bstats) < 0 ||
192 gnet_stats_copy_queue(d, &sch->qstats) < 0) 198 gnet_stats_copy_queue(d, &sch->qstats) < 0)
193 return -1; 199 return -1;
diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
index 069f81c97277..7db2c88ce585 100644
--- a/net/sched/sch_multiq.c
+++ b/net/sched/sch_multiq.c
@@ -359,6 +359,7 @@ static int multiq_dump_class_stats(struct Qdisc *sch, unsigned long cl,
359 struct Qdisc *cl_q; 359 struct Qdisc *cl_q;
360 360
361 cl_q = q->queues[cl - 1]; 361 cl_q = q->queues[cl - 1];
362 cl_q->qstats.qlen = cl_q->q.qlen;
362 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || 363 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 ||
363 gnet_stats_copy_queue(d, &cl_q->qstats) < 0) 364 gnet_stats_copy_queue(d, &cl_q->qstats) < 0)
364 return -1; 365 return -1;
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 0f73c412d04b..93285cecb246 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -322,6 +322,7 @@ static int prio_dump_class_stats(struct Qdisc *sch, unsigned long cl,
322 struct Qdisc *cl_q; 322 struct Qdisc *cl_q;
323 323
324 cl_q = q->queues[cl - 1]; 324 cl_q = q->queues[cl - 1];
325 cl_q->qstats.qlen = cl_q->q.qlen;
325 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || 326 if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 ||
326 gnet_stats_copy_queue(d, &cl_q->qstats) < 0) 327 gnet_stats_copy_queue(d, &cl_q->qstats) < 0)
327 return -1; 328 return -1;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 6a4b19094143..bb280e60e00a 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -949,7 +949,7 @@ static int sctp6_rcv(struct sk_buff *skb)
949 return sctp_rcv(skb) ? -1 : 0; 949 return sctp_rcv(skb) ? -1 : 0;
950} 950}
951 951
952static struct inet6_protocol sctpv6_protocol = { 952static const struct inet6_protocol sctpv6_protocol = {
953 .handler = sctp6_rcv, 953 .handler = sctp6_rcv,
954 .err_handler = sctp_v6_err, 954 .err_handler = sctp_v6_err,
955 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, 955 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 60093be8385d..c557f1fb1c66 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -924,7 +924,7 @@ static struct inet_protosw sctp_stream_protosw = {
924}; 924};
925 925
926/* Register with IP layer. */ 926/* Register with IP layer. */
927static struct net_protocol sctp_protocol = { 927static const struct net_protocol sctp_protocol = {
928 .handler = sctp_rcv, 928 .handler = sctp_rcv,
929 .err_handler = sctp_v4_err, 929 .err_handler = sctp_v4_err,
930 .no_policy = 1, 930 .no_policy = 1,
diff --git a/net/socket.c b/net/socket.c
index 6d4716559047..2a022c00d85c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -489,6 +489,7 @@ static struct socket *sock_alloc(void)
489 489
490 sock = SOCKET_I(inode); 490 sock = SOCKET_I(inode);
491 491
492 kmemcheck_annotate_bitfield(sock, type);
492 inode->i_mode = S_IFSOCK | S_IRWXUGO; 493 inode->i_mode = S_IFSOCK | S_IRWXUGO;
493 inode->i_uid = current_fsuid(); 494 inode->i_uid = current_fsuid();
494 inode->i_gid = current_fsgid(); 495 inode->i_gid = current_fsgid();
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 4c210c2debc6..e5f92ee758f4 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -662,7 +662,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
662 int k; 662 int k;
663 int wiphy_freq = wiphy->bands[band]->channels[j].center_freq; 663 int wiphy_freq = wiphy->bands[band]->channels[j].center_freq;
664 for (k = 0; k < wreq->num_channels; k++) { 664 for (k = 0; k < wreq->num_channels; k++) {
665 int wext_freq = wreq->channel_list[k].m / 100000; 665 int wext_freq = cfg80211_wext_freq(wiphy, &wreq->channel_list[k]);
666 if (wext_freq == wiphy_freq) 666 if (wext_freq == wiphy_freq)
667 goto wext_freq_found; 667 goto wext_freq_found;
668 } 668 }
@@ -675,6 +675,11 @@ int cfg80211_wext_siwscan(struct net_device *dev,
675 wext_freq_not_found: ; 675 wext_freq_not_found: ;
676 } 676 }
677 } 677 }
678 /* No channels found? */
679 if (!i) {
680 err = -EINVAL;
681 goto out;
682 }
678 683
679 /* Set real number of channels specified in creq->channels[] */ 684 /* Set real number of channels specified in creq->channels[] */
680 creq->n_channels = i; 685 creq->n_channels = i;
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 68307883ec87..7fae7eee65de 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -188,7 +188,7 @@ void cfg80211_conn_work(struct work_struct *work)
188 rtnl_unlock(); 188 rtnl_unlock();
189} 189}
190 190
191static bool cfg80211_get_conn_bss(struct wireless_dev *wdev) 191static struct cfg80211_bss *cfg80211_get_conn_bss(struct wireless_dev *wdev)
192{ 192{
193 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 193 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
194 struct cfg80211_bss *bss; 194 struct cfg80211_bss *bss;
@@ -205,7 +205,7 @@ static bool cfg80211_get_conn_bss(struct wireless_dev *wdev)
205 WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_PRIVACY, 205 WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_PRIVACY,
206 capa); 206 capa);
207 if (!bss) 207 if (!bss)
208 return false; 208 return NULL;
209 209
210 memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN); 210 memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN);
211 wdev->conn->params.bssid = wdev->conn->bssid; 211 wdev->conn->params.bssid = wdev->conn->bssid;
@@ -213,14 +213,14 @@ static bool cfg80211_get_conn_bss(struct wireless_dev *wdev)
213 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; 213 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
214 schedule_work(&rdev->conn_work); 214 schedule_work(&rdev->conn_work);
215 215
216 cfg80211_put_bss(bss); 216 return bss;
217 return true;
218} 217}
219 218
220static void __cfg80211_sme_scan_done(struct net_device *dev) 219static void __cfg80211_sme_scan_done(struct net_device *dev)
221{ 220{
222 struct wireless_dev *wdev = dev->ieee80211_ptr; 221 struct wireless_dev *wdev = dev->ieee80211_ptr;
223 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 222 struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
223 struct cfg80211_bss *bss;
224 224
225 ASSERT_WDEV_LOCK(wdev); 225 ASSERT_WDEV_LOCK(wdev);
226 226
@@ -234,7 +234,10 @@ static void __cfg80211_sme_scan_done(struct net_device *dev)
234 wdev->conn->state != CFG80211_CONN_SCAN_AGAIN) 234 wdev->conn->state != CFG80211_CONN_SCAN_AGAIN)
235 return; 235 return;
236 236
237 if (!cfg80211_get_conn_bss(wdev)) { 237 bss = cfg80211_get_conn_bss(wdev);
238 if (bss) {
239 cfg80211_put_bss(bss);
240 } else {
238 /* not found */ 241 /* not found */
239 if (wdev->conn->state == CFG80211_CONN_SCAN_AGAIN) 242 if (wdev->conn->state == CFG80211_CONN_SCAN_AGAIN)
240 schedule_work(&rdev->conn_work); 243 schedule_work(&rdev->conn_work);
@@ -670,6 +673,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
670{ 673{
671 struct wireless_dev *wdev = dev->ieee80211_ptr; 674 struct wireless_dev *wdev = dev->ieee80211_ptr;
672 struct ieee80211_channel *chan; 675 struct ieee80211_channel *chan;
676 struct cfg80211_bss *bss = NULL;
673 int err; 677 int err;
674 678
675 ASSERT_WDEV_LOCK(wdev); 679 ASSERT_WDEV_LOCK(wdev);
@@ -760,7 +764,7 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
760 764
761 /* don't care about result -- but fill bssid & channel */ 765 /* don't care about result -- but fill bssid & channel */
762 if (!wdev->conn->params.bssid || !wdev->conn->params.channel) 766 if (!wdev->conn->params.bssid || !wdev->conn->params.channel)
763 cfg80211_get_conn_bss(wdev); 767 bss = cfg80211_get_conn_bss(wdev);
764 768
765 wdev->sme_state = CFG80211_SME_CONNECTING; 769 wdev->sme_state = CFG80211_SME_CONNECTING;
766 wdev->connect_keys = connkeys; 770 wdev->connect_keys = connkeys;
@@ -770,10 +774,11 @@ int __cfg80211_connect(struct cfg80211_registered_device *rdev,
770 wdev->conn->prev_bssid_valid = true; 774 wdev->conn->prev_bssid_valid = true;
771 } 775 }
772 776
773 /* we're good if we have both BSSID and channel */ 777 /* we're good if we have a matching bss struct */
774 if (wdev->conn->params.bssid && wdev->conn->params.channel) { 778 if (bss) {
775 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; 779 wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
776 err = cfg80211_conn_do_work(wdev); 780 err = cfg80211_conn_do_work(wdev);
781 cfg80211_put_bss(bss);
777 } else { 782 } else {
778 /* otherwise we'll need to scan for the AP first */ 783 /* otherwise we'll need to scan for the AP first */
779 err = cfg80211_conn_scan(wdev); 784 err = cfg80211_conn_scan(wdev);