aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/sm_make_chunk.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-08-07 03:29:57 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-15 02:32:16 -0400
commite1fc3b14f9a90d9591016749289f2c3d7b35fbf4 (patch)
tree709a6cfe1ac2d7164c9661a8c393a91d83ee6c85 /net/sctp/sm_make_chunk.c
parentf53b5b097e58361668b785eff9f7bcd12b4255ec (diff)
sctp: Make sysctl tunables per net
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/sm_make_chunk.c')
-rw-r--r--net/sctp/sm_make_chunk.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index a4b096f85a68..fbe1636309a7 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -198,6 +198,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
198 const struct sctp_bind_addr *bp, 198 const struct sctp_bind_addr *bp,
199 gfp_t gfp, int vparam_len) 199 gfp_t gfp, int vparam_len)
200{ 200{
201 struct net *net = sock_net(asoc->base.sk);
201 sctp_inithdr_t init; 202 sctp_inithdr_t init;
202 union sctp_params addrs; 203 union sctp_params addrs;
203 size_t chunksize; 204 size_t chunksize;
@@ -237,7 +238,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
237 chunksize += WORD_ROUND(SCTP_SAT_LEN(num_types)); 238 chunksize += WORD_ROUND(SCTP_SAT_LEN(num_types));
238 chunksize += sizeof(ecap_param); 239 chunksize += sizeof(ecap_param);
239 240
240 if (sctp_prsctp_enable) 241 if (net->sctp.prsctp_enable)
241 chunksize += sizeof(prsctp_param); 242 chunksize += sizeof(prsctp_param);
242 243
243 /* ADDIP: Section 4.2.7: 244 /* ADDIP: Section 4.2.7:
@@ -245,7 +246,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
245 * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and 246 * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and
246 * INIT-ACK parameters. 247 * INIT-ACK parameters.
247 */ 248 */
248 if (sctp_addip_enable) { 249 if (net->sctp.addip_enable) {
249 extensions[num_ext] = SCTP_CID_ASCONF; 250 extensions[num_ext] = SCTP_CID_ASCONF;
250 extensions[num_ext+1] = SCTP_CID_ASCONF_ACK; 251 extensions[num_ext+1] = SCTP_CID_ASCONF_ACK;
251 num_ext += 2; 252 num_ext += 2;
@@ -257,7 +258,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
257 chunksize += vparam_len; 258 chunksize += vparam_len;
258 259
259 /* Account for AUTH related parameters */ 260 /* Account for AUTH related parameters */
260 if (sctp_auth_enable) { 261 if (net->sctp.auth_enable) {
261 /* Add random parameter length*/ 262 /* Add random parameter length*/
262 chunksize += sizeof(asoc->c.auth_random); 263 chunksize += sizeof(asoc->c.auth_random);
263 264
@@ -331,7 +332,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
331 sctp_addto_param(retval, num_ext, extensions); 332 sctp_addto_param(retval, num_ext, extensions);
332 } 333 }
333 334
334 if (sctp_prsctp_enable) 335 if (net->sctp.prsctp_enable)
335 sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); 336 sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param);
336 337
337 if (sp->adaptation_ind) { 338 if (sp->adaptation_ind) {
@@ -342,7 +343,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
342 } 343 }
343 344
344 /* Add SCTP-AUTH chunks to the parameter list */ 345 /* Add SCTP-AUTH chunks to the parameter list */
345 if (sctp_auth_enable) { 346 if (net->sctp.auth_enable) {
346 sctp_addto_chunk(retval, sizeof(asoc->c.auth_random), 347 sctp_addto_chunk(retval, sizeof(asoc->c.auth_random),
347 asoc->c.auth_random); 348 asoc->c.auth_random);
348 if (auth_hmacs) 349 if (auth_hmacs)
@@ -1964,10 +1965,10 @@ static int sctp_verify_ext_param(struct net *net, union sctp_params param)
1964 * only if ADD-IP is turned on and we are not backward-compatible 1965 * only if ADD-IP is turned on and we are not backward-compatible
1965 * mode. 1966 * mode.
1966 */ 1967 */
1967 if (sctp_addip_noauth) 1968 if (net->sctp.addip_noauth)
1968 return 1; 1969 return 1;
1969 1970
1970 if (sctp_addip_enable && !have_auth && have_asconf) 1971 if (net->sctp.addip_enable && !have_auth && have_asconf)
1971 return 0; 1972 return 0;
1972 1973
1973 return 1; 1974 return 1;
@@ -1976,13 +1977,14 @@ static int sctp_verify_ext_param(struct net *net, union sctp_params param)
1976static void sctp_process_ext_param(struct sctp_association *asoc, 1977static void sctp_process_ext_param(struct sctp_association *asoc,
1977 union sctp_params param) 1978 union sctp_params param)
1978{ 1979{
1980 struct net *net = sock_net(asoc->base.sk);
1979 __u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t); 1981 __u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t);
1980 int i; 1982 int i;
1981 1983
1982 for (i = 0; i < num_ext; i++) { 1984 for (i = 0; i < num_ext; i++) {
1983 switch (param.ext->chunks[i]) { 1985 switch (param.ext->chunks[i]) {
1984 case SCTP_CID_FWD_TSN: 1986 case SCTP_CID_FWD_TSN:
1985 if (sctp_prsctp_enable && 1987 if (net->sctp.prsctp_enable &&
1986 !asoc->peer.prsctp_capable) 1988 !asoc->peer.prsctp_capable)
1987 asoc->peer.prsctp_capable = 1; 1989 asoc->peer.prsctp_capable = 1;
1988 break; 1990 break;
@@ -1990,12 +1992,12 @@ static void sctp_process_ext_param(struct sctp_association *asoc,
1990 /* if the peer reports AUTH, assume that he 1992 /* if the peer reports AUTH, assume that he
1991 * supports AUTH. 1993 * supports AUTH.
1992 */ 1994 */
1993 if (sctp_auth_enable) 1995 if (net->sctp.auth_enable)
1994 asoc->peer.auth_capable = 1; 1996 asoc->peer.auth_capable = 1;
1995 break; 1997 break;
1996 case SCTP_CID_ASCONF: 1998 case SCTP_CID_ASCONF:
1997 case SCTP_CID_ASCONF_ACK: 1999 case SCTP_CID_ASCONF_ACK:
1998 if (sctp_addip_enable) 2000 if (net->sctp.addip_enable)
1999 asoc->peer.asconf_capable = 1; 2001 asoc->peer.asconf_capable = 1;
2000 break; 2002 break;
2001 default: 2003 default:
@@ -2116,7 +2118,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
2116 break; 2118 break;
2117 2119
2118 case SCTP_PARAM_SET_PRIMARY: 2120 case SCTP_PARAM_SET_PRIMARY:
2119 if (sctp_addip_enable) 2121 if (net->sctp.addip_enable)
2120 break; 2122 break;
2121 goto fallthrough; 2123 goto fallthrough;
2122 2124
@@ -2127,12 +2129,12 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
2127 break; 2129 break;
2128 2130
2129 case SCTP_PARAM_FWD_TSN_SUPPORT: 2131 case SCTP_PARAM_FWD_TSN_SUPPORT:
2130 if (sctp_prsctp_enable) 2132 if (net->sctp.prsctp_enable)
2131 break; 2133 break;
2132 goto fallthrough; 2134 goto fallthrough;
2133 2135
2134 case SCTP_PARAM_RANDOM: 2136 case SCTP_PARAM_RANDOM:
2135 if (!sctp_auth_enable) 2137 if (!net->sctp.auth_enable)
2136 goto fallthrough; 2138 goto fallthrough;
2137 2139
2138 /* SCTP-AUTH: Secion 6.1 2140 /* SCTP-AUTH: Secion 6.1
@@ -2149,7 +2151,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
2149 break; 2151 break;
2150 2152
2151 case SCTP_PARAM_CHUNKS: 2153 case SCTP_PARAM_CHUNKS:
2152 if (!sctp_auth_enable) 2154 if (!net->sctp.auth_enable)
2153 goto fallthrough; 2155 goto fallthrough;
2154 2156
2155 /* SCTP-AUTH: Section 3.2 2157 /* SCTP-AUTH: Section 3.2
@@ -2165,7 +2167,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
2165 break; 2167 break;
2166 2168
2167 case SCTP_PARAM_HMAC_ALGO: 2169 case SCTP_PARAM_HMAC_ALGO:
2168 if (!sctp_auth_enable) 2170 if (!net->sctp.auth_enable)
2169 goto fallthrough; 2171 goto fallthrough;
2170 2172
2171 hmacs = (struct sctp_hmac_algo_param *)param.p; 2173 hmacs = (struct sctp_hmac_algo_param *)param.p;
@@ -2271,6 +2273,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
2271 const union sctp_addr *peer_addr, 2273 const union sctp_addr *peer_addr,
2272 sctp_init_chunk_t *peer_init, gfp_t gfp) 2274 sctp_init_chunk_t *peer_init, gfp_t gfp)
2273{ 2275{
2276 struct net *net = sock_net(asoc->base.sk);
2274 union sctp_params param; 2277 union sctp_params param;
2275 struct sctp_transport *transport; 2278 struct sctp_transport *transport;
2276 struct list_head *pos, *temp; 2279 struct list_head *pos, *temp;
@@ -2327,7 +2330,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
2327 * also give us an option to silently ignore the packet, which 2330 * also give us an option to silently ignore the packet, which
2328 * is what we'll do here. 2331 * is what we'll do here.
2329 */ 2332 */
2330 if (!sctp_addip_noauth && 2333 if (!net->sctp.addip_noauth &&
2331 (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) { 2334 (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) {
2332 asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP | 2335 asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP |
2333 SCTP_PARAM_DEL_IP | 2336 SCTP_PARAM_DEL_IP |
@@ -2502,7 +2505,7 @@ do_addr_param:
2502 break; 2505 break;
2503 2506
2504 case SCTP_PARAM_COOKIE_PRESERVATIVE: 2507 case SCTP_PARAM_COOKIE_PRESERVATIVE:
2505 if (!sctp_cookie_preserve_enable) 2508 if (!net->sctp.cookie_preserve_enable)
2506 break; 2509 break;
2507 2510
2508 stale = ntohl(param.life->lifespan_increment); 2511 stale = ntohl(param.life->lifespan_increment);
@@ -2582,7 +2585,7 @@ do_addr_param:
2582 break; 2585 break;
2583 2586
2584 case SCTP_PARAM_SET_PRIMARY: 2587 case SCTP_PARAM_SET_PRIMARY:
2585 if (!sctp_addip_enable) 2588 if (!net->sctp.addip_enable)
2586 goto fall_through; 2589 goto fall_through;
2587 2590
2588 addr_param = param.v + sizeof(sctp_addip_param_t); 2591 addr_param = param.v + sizeof(sctp_addip_param_t);
@@ -2609,7 +2612,7 @@ do_addr_param:
2609 break; 2612 break;
2610 2613
2611 case SCTP_PARAM_FWD_TSN_SUPPORT: 2614 case SCTP_PARAM_FWD_TSN_SUPPORT:
2612 if (sctp_prsctp_enable) { 2615 if (net->sctp.prsctp_enable) {
2613 asoc->peer.prsctp_capable = 1; 2616 asoc->peer.prsctp_capable = 1;
2614 break; 2617 break;
2615 } 2618 }
@@ -2617,7 +2620,7 @@ do_addr_param:
2617 goto fall_through; 2620 goto fall_through;
2618 2621
2619 case SCTP_PARAM_RANDOM: 2622 case SCTP_PARAM_RANDOM:
2620 if (!sctp_auth_enable) 2623 if (!net->sctp.auth_enable)
2621 goto fall_through; 2624 goto fall_through;
2622 2625
2623 /* Save peer's random parameter */ 2626 /* Save peer's random parameter */
@@ -2630,7 +2633,7 @@ do_addr_param:
2630 break; 2633 break;
2631 2634
2632 case SCTP_PARAM_HMAC_ALGO: 2635 case SCTP_PARAM_HMAC_ALGO:
2633 if (!sctp_auth_enable) 2636 if (!net->sctp.auth_enable)
2634 goto fall_through; 2637 goto fall_through;
2635 2638
2636 /* Save peer's HMAC list */ 2639 /* Save peer's HMAC list */
@@ -2646,7 +2649,7 @@ do_addr_param:
2646 break; 2649 break;
2647 2650
2648 case SCTP_PARAM_CHUNKS: 2651 case SCTP_PARAM_CHUNKS:
2649 if (!sctp_auth_enable) 2652 if (!net->sctp.auth_enable)
2650 goto fall_through; 2653 goto fall_through;
2651 2654
2652 asoc->peer.peer_chunks = kmemdup(param.p, 2655 asoc->peer.peer_chunks = kmemdup(param.p,