Skip to content

Commit 30f6ebf

Browse files
lxindavem330
authored andcommitted
sctp: add SCTP_AUTH_NO_AUTH type for AUTHENTICATION_EVENT
This patch is to add SCTP_AUTH_NO_AUTH type for AUTHENTICATION_EVENT, as described in section 6.1.8 of RFC6458. SCTP_AUTH_NO_AUTH: This report indicates that the peer does not support SCTP authentication as defined in [RFC4895]. Note that the implementation is quite similar as that of SCTP_ADAPTATION_INDICATION. Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ec2e506 commit 30f6ebf

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

include/net/sctp/command.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ enum sctp_verb {
100100
SCTP_CMD_SET_SK_ERR, /* Set sk_err */
101101
SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */
102102
SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */
103+
SCTP_CMD_PEER_NO_AUTH, /* generate and send authentication event */
103104
SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */
104105
SCTP_CMD_T1_RETRAN, /* Mark for retransmission after T1 timeout */
105106
SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */

include/uapi/linux/sctp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ enum {
522522
SCTP_AUTH_NEW_KEY,
523523
#define SCTP_AUTH_NEWKEY SCTP_AUTH_NEW_KEY /* compatible with before */
524524
SCTP_AUTH_FREE_KEY,
525+
SCTP_AUTH_NO_AUTH,
525526
};
526527

527528
/*

net/sctp/sm_sideeffect.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,16 @@ static void sctp_cmd_assoc_change(struct sctp_cmd_seq *commands,
10491049
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
10501050
}
10511051

1052+
static void sctp_cmd_peer_no_auth(struct sctp_cmd_seq *commands,
1053+
struct sctp_association *asoc)
1054+
{
1055+
struct sctp_ulpevent *ev;
1056+
1057+
ev = sctp_ulpevent_make_authkey(asoc, 0, SCTP_AUTH_NO_AUTH, GFP_ATOMIC);
1058+
if (ev)
1059+
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
1060+
}
1061+
10521062
/* Helper function to generate an adaptation indication event */
10531063
static void sctp_cmd_adaptation_ind(struct sctp_cmd_seq *commands,
10541064
struct sctp_association *asoc)
@@ -1755,6 +1765,9 @@ static int sctp_cmd_interpreter(enum sctp_event event_type,
17551765
case SCTP_CMD_ADAPTATION_IND:
17561766
sctp_cmd_adaptation_ind(commands, asoc);
17571767
break;
1768+
case SCTP_CMD_PEER_NO_AUTH:
1769+
sctp_cmd_peer_no_auth(commands, asoc);
1770+
break;
17581771

17591772
case SCTP_CMD_ASSOC_SHKEY:
17601773
error = sctp_auth_asoc_init_active_key(asoc,

net/sctp/sm_statefuns.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
659659
void *arg,
660660
struct sctp_cmd_seq *commands)
661661
{
662-
struct sctp_ulpevent *ev, *ai_ev = NULL;
662+
struct sctp_ulpevent *ev, *ai_ev = NULL, *auth_ev = NULL;
663663
struct sctp_association *new_asoc;
664664
struct sctp_init_chunk *peer_init;
665665
struct sctp_chunk *chunk = arg;
@@ -820,6 +820,14 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
820820
goto nomem_aiev;
821821
}
822822

823+
if (!new_asoc->peer.auth_capable) {
824+
auth_ev = sctp_ulpevent_make_authkey(new_asoc, 0,
825+
SCTP_AUTH_NO_AUTH,
826+
GFP_ATOMIC);
827+
if (!auth_ev)
828+
goto nomem_authev;
829+
}
830+
823831
/* Add all the state machine commands now since we've created
824832
* everything. This way we don't introduce memory corruptions
825833
* during side-effect processing and correclty count established
@@ -847,8 +855,14 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
847855
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
848856
SCTP_ULPEVENT(ai_ev));
849857

858+
if (auth_ev)
859+
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
860+
SCTP_ULPEVENT(auth_ev));
861+
850862
return SCTP_DISPOSITION_CONSUME;
851863

864+
nomem_authev:
865+
sctp_ulpevent_free(ai_ev);
852866
nomem_aiev:
853867
sctp_ulpevent_free(ev);
854868
nomem_ev:
@@ -953,6 +967,15 @@ enum sctp_disposition sctp_sf_do_5_1E_ca(struct net *net,
953967
SCTP_ULPEVENT(ev));
954968
}
955969

970+
if (!asoc->peer.auth_capable) {
971+
ev = sctp_ulpevent_make_authkey(asoc, 0, SCTP_AUTH_NO_AUTH,
972+
GFP_ATOMIC);
973+
if (!ev)
974+
goto nomem;
975+
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
976+
SCTP_ULPEVENT(ev));
977+
}
978+
956979
return SCTP_DISPOSITION_CONSUME;
957980
nomem:
958981
return SCTP_DISPOSITION_NOMEM;
@@ -1908,6 +1931,9 @@ static enum sctp_disposition sctp_sf_do_dupcook_b(
19081931
if (asoc->peer.adaptation_ind)
19091932
sctp_add_cmd_sf(commands, SCTP_CMD_ADAPTATION_IND, SCTP_NULL());
19101933

1934+
if (!asoc->peer.auth_capable)
1935+
sctp_add_cmd_sf(commands, SCTP_CMD_PEER_NO_AUTH, SCTP_NULL());
1936+
19111937
return SCTP_DISPOSITION_CONSUME;
19121938

19131939
nomem:
@@ -1954,7 +1980,7 @@ static enum sctp_disposition sctp_sf_do_dupcook_d(
19541980
struct sctp_cmd_seq *commands,
19551981
struct sctp_association *new_asoc)
19561982
{
1957-
struct sctp_ulpevent *ev = NULL, *ai_ev = NULL;
1983+
struct sctp_ulpevent *ev = NULL, *ai_ev = NULL, *auth_ev = NULL;
19581984
struct sctp_chunk *repl;
19591985

19601986
/* Clarification from Implementor's Guide:
@@ -2001,6 +2027,14 @@ static enum sctp_disposition sctp_sf_do_dupcook_d(
20012027
goto nomem;
20022028

20032029
}
2030+
2031+
if (!asoc->peer.auth_capable) {
2032+
auth_ev = sctp_ulpevent_make_authkey(asoc, 0,
2033+
SCTP_AUTH_NO_AUTH,
2034+
GFP_ATOMIC);
2035+
if (!auth_ev)
2036+
goto nomem;
2037+
}
20042038
}
20052039

20062040
repl = sctp_make_cookie_ack(new_asoc, chunk);
@@ -2015,10 +2049,15 @@ static enum sctp_disposition sctp_sf_do_dupcook_d(
20152049
if (ai_ev)
20162050
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
20172051
SCTP_ULPEVENT(ai_ev));
2052+
if (auth_ev)
2053+
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
2054+
SCTP_ULPEVENT(auth_ev));
20182055

20192056
return SCTP_DISPOSITION_CONSUME;
20202057

20212058
nomem:
2059+
if (auth_ev)
2060+
sctp_ulpevent_free(auth_ev);
20222061
if (ai_ev)
20232062
sctp_ulpevent_free(ai_ev);
20242063
if (ev)

0 commit comments

Comments
 (0)