Commit ac49b054 authored by Sridhar Samudrala's avatar Sridhar Samudrala

[SCTP] Adaption layer indication support.

Add support for SCTP_ADAPTION_INDICATION notification, SCTP_ADAPTION_LAYER
socket option and SCTP_PARAM_ADAPTION_LAYER_IND parameter.
Signed-off-by: default avatarSridhar Samudrala <sri@us.ibm.com>
parent 9ae3df72
......@@ -281,7 +281,11 @@ typedef struct sctp_ecn_capable_param {
sctp_paramhdr_t param_hdr;
} __attribute__((packed)) sctp_ecn_capable_param_t;
/* ADDIP Section 3.2.6 Adaption Layer Indication */
typedef struct sctp_adaption_ind_param {
struct sctp_paramhdr param_hdr;
__u32 adaption_ind;
} __attribute__((packed)) sctp_adaption_ind_param_t;
/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
* The INIT ACK chunk is used to acknowledge the initiation of an SCTP
......
......@@ -266,6 +266,7 @@ struct sctp_opt {
__u8 disable_fragments;
__u8 pd_mode;
__u8 v4mapped;
__u32 adaption_ind;
/* Receive to here while partial delivery is in effect. */
struct sk_buff_head pd_lobby;
......@@ -323,6 +324,8 @@ struct sctp_cookie {
__u8 prsctp_capable;
__u32 adaption_ind;
/* This is a shim for my peer's INIT packet, followed by
* a copy of the raw address list of the association.
* The length of the raw address list is saved in the
......@@ -362,6 +365,7 @@ union sctp_params {
struct sctp_ipv4addr_param *v4;
struct sctp_ipv6addr_param *v6;
union sctp_addr_param *addr;
struct sctp_adaption_ind_param *aind;
};
/* RFC 2960. Section 3.3.5 Heartbeat.
......@@ -1395,6 +1399,8 @@ struct sctp_association {
__u8 asconf_capable; /* Does peer support ADDIP? */
__u8 prsctp_capable; /* Can peer do PR-SCTP? */
__u32 adaption_ind; /* Adaption Code point. */
/* This mask is used to disable sending the ASCONF chunk
* with specified parameter to peer.
*/
......
......@@ -121,6 +121,9 @@ struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
const struct sctp_association *asoc,
__u32 indication, int gfp);
struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
const struct sctp_association *asoc, int gfp);
struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
struct sctp_chunk *chunk,
int gfp);
......
......@@ -171,6 +171,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
struct sctp_opt *sp;
sctp_supported_addrs_param_t sat;
__u16 types[2];
sctp_adaption_ind_param_t aiparam;
/* RFC 2960 3.3.2 Initiation (INIT) (1)
*
......@@ -196,6 +197,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
chunksize += sizeof(ecap_param);
if (sctp_prsctp_enable)
chunksize += sizeof(prsctp_param);
chunksize += sizeof(aiparam);
chunksize += vparam_len;
/* RFC 2960 3.3.2 Initiation (INIT) (1)
......@@ -234,6 +236,10 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param);
if (sctp_prsctp_enable)
sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param);
aiparam.param_hdr.type = SCTP_PARAM_ADAPTION_LAYER_IND;
aiparam.param_hdr.length = htons(sizeof(aiparam));
aiparam.adaption_ind = htonl(sp->adaption_ind);
sctp_addto_chunk(retval, sizeof(aiparam), &aiparam);
nodata:
if (addrs.v)
kfree(addrs.v);
......@@ -251,6 +257,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
sctp_cookie_param_t *cookie;
int cookie_len;
size_t chunksize;
sctp_adaption_ind_param_t aiparam;
retval = NULL;
......@@ -284,6 +291,8 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
if (asoc->peer.prsctp_capable)
chunksize += sizeof(prsctp_param);
chunksize += sizeof(aiparam);
/* Now allocate and fill out the chunk. */
retval = sctp_make_chunk(asoc, SCTP_CID_INIT_ACK, 0, chunksize);
if (!retval)
......@@ -302,6 +311,11 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
if (asoc->peer.prsctp_capable)
sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param);
aiparam.param_hdr.type = SCTP_PARAM_ADAPTION_LAYER_IND;
aiparam.param_hdr.length = htons(sizeof(aiparam));
aiparam.adaption_ind = htonl(sctp_sk(asoc->base.sk)->adaption_ind);
sctp_addto_chunk(retval, sizeof(aiparam), &aiparam);
/* We need to remove the const qualifier at this point. */
retval->asoc = (struct sctp_association *) asoc;
......@@ -1297,6 +1311,9 @@ sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
/* Remember PR-SCTP capability. */
cookie->c.prsctp_capable = asoc->peer.prsctp_capable;
/* Save adaption indication in the cookie. */
cookie->c.adaption_ind = asoc->peer.adaption_ind;
/* Set an expiration time for the cookie. */
do_gettimeofday(&cookie->c.expiration);
TIMEVAL_ADD(asoc->cookie_life, cookie->c.expiration);
......@@ -1455,6 +1472,7 @@ struct sctp_association *sctp_unpack_cookie(
retval->addip_serial = retval->c.initial_tsn;
retval->adv_peer_ack_point = retval->ctsn_ack_point;
retval->peer.prsctp_capable = retval->c.prsctp_capable;
retval->peer.adaption_ind = retval->c.adaption_ind;
/* The INIT stuff will be done by the side effects. */
return retval;
......@@ -1661,6 +1679,7 @@ static int sctp_verify_param(const struct sctp_association *asoc,
case SCTP_PARAM_HEARTBEAT_INFO:
case SCTP_PARAM_UNRECOGNIZED_PARAMETERS:
case SCTP_PARAM_ECN_CAPABLE:
case SCTP_PARAM_ADAPTION_LAYER_IND:
break;
case SCTP_PARAM_HOST_NAME_ADDRESS:
......@@ -1989,6 +2008,10 @@ int sctp_process_param(struct sctp_association *asoc, union sctp_params param,
asoc->peer.ecn_capable = 1;
break;
case SCTP_PARAM_ADAPTION_LAYER_IND:
asoc->peer.adaption_ind = param.aind->adaption_ind;
break;
case SCTP_PARAM_FWD_TSN_SUPPORT:
if (sctp_prsctp_enable) {
asoc->peer.prsctp_capable = 1;
......
......@@ -629,6 +629,21 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
/* Sockets API Draft Section 5.3.1.6
* When a peer sends a Adaption Layer Indication parameter , SCTP
* delivers this notification to inform the application that of the
* peers requested adaption layer.
*/
if (new_asoc->peer.adaption_ind) {
ev = sctp_ulpevent_make_adaption_indication(new_asoc,
GFP_ATOMIC);
if (!ev)
goto nomem_ev;
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
SCTP_ULPEVENT(ev));
}
return SCTP_DISPOSITION_CONSUME;
nomem_ev:
......@@ -713,6 +728,20 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep,
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
/* Sockets API Draft Section 5.3.1.6
* When a peer sends a Adaption Layer Indication parameter , SCTP
* delivers this notification to inform the application that of the
* peers requested adaption layer.
*/
if (asoc->peer.adaption_ind) {
ev = sctp_ulpevent_make_adaption_indication(asoc, GFP_ATOMIC);
if (!ev)
goto nomem;
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
SCTP_ULPEVENT(ev));
}
return SCTP_DISPOSITION_CONSUME;
nomem:
return SCTP_DISPOSITION_NOMEM;
......@@ -1532,6 +1561,21 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep,
goto nomem_ev;
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
/* Sockets API Draft Section 5.3.1.6
* When a peer sends a Adaption Layer Indication parameter , SCTP
* delivers this notification to inform the application that of the
* peers requested adaption layer.
*/
if (asoc->peer.adaption_ind) {
ev = sctp_ulpevent_make_adaption_indication(asoc, GFP_ATOMIC);
if (!ev)
goto nomem_ev;
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
SCTP_ULPEVENT(ev));
}
return SCTP_DISPOSITION_CONSUME;
nomem_ev:
......@@ -1612,6 +1656,21 @@ static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep,
goto nomem;
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
SCTP_ULPEVENT(ev));
/* Sockets API Draft Section 5.3.1.6
* When a peer sends a Adaption Layer Indication parameter,
* SCTP delivers this notification to inform the application
* that of the peers requested adaption layer.
*/
if (new_asoc->peer.adaption_ind) {
ev = sctp_ulpevent_make_adaption_indication(new_asoc,
GFP_ATOMIC);
if (!ev)
goto nomem;
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
SCTP_ULPEVENT(ev));
}
}
sctp_add_cmd_sf(commands, SCTP_CMD_TRANSMIT, SCTP_NULL());
......
......@@ -2120,6 +2120,20 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
return err;
}
static int sctp_setsockopt_adaption_layer(struct sock *sk, char __user *optval,
int optlen)
{
__u32 val;
if (optlen < sizeof(__u32))
return -EINVAL;
if (copy_from_user(&val, optval, sizeof(__u32)))
return -EFAULT;
sctp_sk(sk)->adaption_ind = val;
return 0;
}
/* API 6.2 setsockopt(), getsockopt()
*
......@@ -2219,6 +2233,10 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname,
case SCTP_MAXSEG:
retval = sctp_setsockopt_maxseg(sk, optval, optlen);
break;
case SCTP_ADAPTION_LAYER:
retval = sctp_setsockopt_adaption_layer(sk, optval, optlen);
break;
default:
retval = -ENOPROTOOPT;
break;
......@@ -2518,6 +2536,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
/* User specified fragmentation limit. */
sp->user_frag = 0;
sp->adaption_ind = 0;
sp->pf = sctp_get_pf_specific(sk->sk_family);
/* Control variables for partial data delivery. */
......@@ -3159,6 +3179,29 @@ static int sctp_getsockopt_primary_addr(struct sock *sk, int len,
return 0;
}
/*
* 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER)
*
* Requests that the local endpoint set the specified Adaption Layer
* Indication parameter for all future INIT and INIT-ACK exchanges.
*/
static int sctp_getsockopt_adaption_layer(struct sock *sk, int len,
char __user *optval, int __user *optlen)
{
__u32 val;
if (len < sizeof(__u32))
return -EINVAL;
len = sizeof(__u32);
val = sctp_sk(sk)->adaption_ind;
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(optval, &val, len))
return -EFAULT;
return 0;
}
/*
*
* 7.1.14 Set default send parameters (SCTP_DEFAULT_SEND_PARAM)
......@@ -3515,6 +3558,10 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
retval = sctp_getsockopt_peer_addr_info(sk, len, optval,
optlen);
break;
case SCTP_ADAPTION_LAYER:
retval = sctp_getsockopt_adaption_layer(sk, len, optval,
optlen);
break;
default:
retval = -ENOPROTOOPT;
break;
......
......@@ -562,7 +562,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
struct sctp_shutdown_event *sse;
struct sk_buff *skb;
event = sctp_ulpevent_new(sizeof(struct sctp_assoc_change),
event = sctp_ulpevent_new(sizeof(struct sctp_shutdown_event),
MSG_NOTIFICATION, gfp);
if (!event)
goto fail;
......@@ -613,6 +613,40 @@ struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
return NULL;
}
/* Create and initialize a SCTP_ADAPTION_INDICATION notification.
*
* Socket Extensions for SCTP
* 5.3.1.6 SCTP_ADAPTION_INDICATION
*/
struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication(
const struct sctp_association *asoc, int gfp)
{
struct sctp_ulpevent *event;
struct sctp_adaption_event *sai;
struct sk_buff *skb;
event = sctp_ulpevent_new(sizeof(struct sctp_adaption_event),
MSG_NOTIFICATION, gfp);
if (!event)
goto fail;
skb = sctp_event2skb(event);
sai = (struct sctp_adaption_event *)
skb_put(skb, sizeof(struct sctp_adaption_event));
sai->sai_type = SCTP_ADAPTION_INDICATION;
sai->sai_flags = 0;
sai->sai_length = sizeof(struct sctp_adaption_event);
sai->sai_adaption_ind = asoc->peer.adaption_ind;
sctp_ulpevent_set_owner(event, asoc);
sai->sai_assoc_id = sctp_assoc2id(asoc);
return event;
fail:
return NULL;
}
/* A message has been received. Package this message as a notification
* to pass it to the upper layers. Go ahead and calculate the sndrcvinfo
* even if filtered out later.
......@@ -689,7 +723,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
struct sctp_pdapi_event *pd;
struct sk_buff *skb;
event = sctp_ulpevent_new(sizeof(struct sctp_assoc_change),
event = sctp_ulpevent_new(sizeof(struct sctp_pdapi_event),
MSG_NOTIFICATION, gfp);
if (!event)
goto fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment