Skip to content

Commit d6de309

Browse files
Vlad Yasevichdavem330
authored andcommitted
[SCTP]: Add the handling of "Set Primary IP Address" parameter to INIT
The ADD-IP "Set Primary IP Address" parameter is allowed in the INIT/INIT-ACK exchange. Allow processing of this parameter during the INIT/INIT-ACK. Signed-off-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 42e30bf commit d6de309

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

include/net/sctp/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ union sctp_params {
451451
struct sctp_random_param *random;
452452
struct sctp_chunks_param *chunks;
453453
struct sctp_hmac_algo_param *hmac_algo;
454+
struct sctp_addip_param *addip;
454455
};
455456

456457
/* RFC 2960. Section 3.3.5 Heartbeat.

net/sctp/sm_make_chunk.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,11 @@ static sctp_ierror_t sctp_verify_param(const struct sctp_association *asoc,
19691969
case SCTP_PARAM_SUPPORTED_EXT:
19701970
break;
19711971

1972+
case SCTP_PARAM_SET_PRIMARY:
1973+
if (sctp_addip_enable)
1974+
break;
1975+
goto fallthrough;
1976+
19721977
case SCTP_PARAM_HOST_NAME_ADDRESS:
19731978
/* Tell the peer, we won't support this param. */
19741979
sctp_process_hn_param(asoc, param, chunk, err_chunk);
@@ -2286,6 +2291,8 @@ static int sctp_process_param(struct sctp_association *asoc,
22862291
sctp_scope_t scope;
22872292
time_t stale;
22882293
struct sctp_af *af;
2294+
union sctp_addr_param *addr_param;
2295+
struct sctp_transport *t;
22892296

22902297
/* We maintain all INIT parameters in network byte order all the
22912298
* time. This allows us to not worry about whether the parameters
@@ -2376,6 +2383,26 @@ static int sctp_process_param(struct sctp_association *asoc,
23762383
asoc->peer.adaptation_ind = param.aind->adaptation_ind;
23772384
break;
23782385

2386+
case SCTP_PARAM_SET_PRIMARY:
2387+
addr_param = param.v + sizeof(sctp_addip_param_t);
2388+
2389+
af = sctp_get_af_specific(param_type2af(param.p->type));
2390+
af->from_addr_param(&addr, addr_param,
2391+
htons(asoc->peer.port), 0);
2392+
2393+
/* if the address is invalid, we can't process it.
2394+
* XXX: see spec for what to do.
2395+
*/
2396+
if (!af->addr_valid(&addr, NULL, NULL))
2397+
break;
2398+
2399+
t = sctp_assoc_lookup_paddr(asoc, &addr);
2400+
if (!t)
2401+
break;
2402+
2403+
sctp_assoc_set_primary(asoc, t);
2404+
break;
2405+
23792406
case SCTP_PARAM_SUPPORTED_EXT:
23802407
sctp_process_ext_param(asoc, param);
23812408
break;

0 commit comments

Comments
 (0)