Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Xin Long and committed by
David S. Miller
30f6ebf6 ec2e506c

+56 -2
+1
include/net/sctp/command.h
··· 100 100 SCTP_CMD_SET_SK_ERR, /* Set sk_err */ 101 101 SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */ 102 102 SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */ 103 + SCTP_CMD_PEER_NO_AUTH, /* generate and send authentication event */ 103 104 SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */ 104 105 SCTP_CMD_T1_RETRAN, /* Mark for retransmission after T1 timeout */ 105 106 SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */
+1
include/uapi/linux/sctp.h
··· 522 522 SCTP_AUTH_NEW_KEY, 523 523 #define SCTP_AUTH_NEWKEY SCTP_AUTH_NEW_KEY /* compatible with before */ 524 524 SCTP_AUTH_FREE_KEY, 525 + SCTP_AUTH_NO_AUTH, 525 526 }; 526 527 527 528 /*
+13
net/sctp/sm_sideeffect.c
··· 1049 1049 asoc->stream.si->enqueue_event(&asoc->ulpq, ev); 1050 1050 } 1051 1051 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 + 1052 1062 /* Helper function to generate an adaptation indication event */ 1053 1063 static void sctp_cmd_adaptation_ind(struct sctp_cmd_seq *commands, 1054 1064 struct sctp_association *asoc) ··· 1764 1754 break; 1765 1755 case SCTP_CMD_ADAPTATION_IND: 1766 1756 sctp_cmd_adaptation_ind(commands, asoc); 1757 + break; 1758 + case SCTP_CMD_PEER_NO_AUTH: 1759 + sctp_cmd_peer_no_auth(commands, asoc); 1767 1760 break; 1768 1761 1769 1762 case SCTP_CMD_ASSOC_SHKEY:
+41 -2
net/sctp/sm_statefuns.c
··· 659 659 void *arg, 660 660 struct sctp_cmd_seq *commands) 661 661 { 662 - struct sctp_ulpevent *ev, *ai_ev = NULL; 662 + struct sctp_ulpevent *ev, *ai_ev = NULL, *auth_ev = NULL; 663 663 struct sctp_association *new_asoc; 664 664 struct sctp_init_chunk *peer_init; 665 665 struct sctp_chunk *chunk = arg; ··· 820 820 goto nomem_aiev; 821 821 } 822 822 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 + 823 831 /* Add all the state machine commands now since we've created 824 832 * everything. This way we don't introduce memory corruptions 825 833 * during side-effect processing and correclty count established ··· 855 847 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 856 848 SCTP_ULPEVENT(ai_ev)); 857 849 850 + if (auth_ev) 851 + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 852 + SCTP_ULPEVENT(auth_ev)); 853 + 858 854 return SCTP_DISPOSITION_CONSUME; 859 855 856 + nomem_authev: 857 + sctp_ulpevent_free(ai_ev); 860 858 nomem_aiev: 861 859 sctp_ulpevent_free(ev); 862 860 nomem_ev: ··· 963 949 if (!ev) 964 950 goto nomem; 965 951 952 + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 953 + SCTP_ULPEVENT(ev)); 954 + } 955 + 956 + if (!asoc->peer.auth_capable) { 957 + ev = sctp_ulpevent_make_authkey(asoc, 0, SCTP_AUTH_NO_AUTH, 958 + GFP_ATOMIC); 959 + if (!ev) 960 + goto nomem; 966 961 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 967 962 SCTP_ULPEVENT(ev)); 968 963 } ··· 1931 1908 if (asoc->peer.adaptation_ind) 1932 1909 sctp_add_cmd_sf(commands, SCTP_CMD_ADAPTATION_IND, SCTP_NULL()); 1933 1910 1911 + if (!asoc->peer.auth_capable) 1912 + sctp_add_cmd_sf(commands, SCTP_CMD_PEER_NO_AUTH, SCTP_NULL()); 1913 + 1934 1914 return SCTP_DISPOSITION_CONSUME; 1935 1915 1936 1916 nomem: ··· 1980 1954 struct sctp_cmd_seq *commands, 1981 1955 struct sctp_association *new_asoc) 1982 1956 { 1983 - struct sctp_ulpevent *ev = NULL, *ai_ev = NULL; 1957 + struct sctp_ulpevent *ev = NULL, *ai_ev = NULL, *auth_ev = NULL; 1984 1958 struct sctp_chunk *repl; 1985 1959 1986 1960 /* Clarification from Implementor's Guide: ··· 2027 2001 goto nomem; 2028 2002 2029 2003 } 2004 + 2005 + if (!asoc->peer.auth_capable) { 2006 + auth_ev = sctp_ulpevent_make_authkey(asoc, 0, 2007 + SCTP_AUTH_NO_AUTH, 2008 + GFP_ATOMIC); 2009 + if (!auth_ev) 2010 + goto nomem; 2011 + } 2030 2012 } 2031 2013 2032 2014 repl = sctp_make_cookie_ack(new_asoc, chunk); ··· 2049 2015 if (ai_ev) 2050 2016 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 2051 2017 SCTP_ULPEVENT(ai_ev)); 2018 + if (auth_ev) 2019 + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 2020 + SCTP_ULPEVENT(auth_ev)); 2052 2021 2053 2022 return SCTP_DISPOSITION_CONSUME; 2054 2023 2055 2024 nomem: 2025 + if (auth_ev) 2026 + sctp_ulpevent_free(auth_ev); 2056 2027 if (ai_ev) 2057 2028 sctp_ulpevent_free(ai_ev); 2058 2029 if (ev)