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

net: sctp: dynamically enable or disable pf state

As we all know, the value of pf_retrans >= max_retrans_path can
disable pf state. The variables of pf_retrans and max_retrans_path
can be changed by the userspace application.

Sometimes the user expects to disable pf state while the 2
variables are changed to enable pf state. So it is necessary to
introduce a new variable to disable pf state.

According to the suggestions from Vlad Yasevich, extra1 and extra2
are removed. The initialization of pf_enable is added.

Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Zhu Yanjun and committed by
David S. Miller
566178f8 6857a02a

+43 -2
+22 -1
Documentation/networking/ip-sysctl.txt
··· 1723 1723 1724 1724 Default: 0 1725 1725 1726 + pf_enable - INTEGER 1727 + Enable or disable pf (pf is short for potentially failed) state. A value 1728 + of pf_retrans > path_max_retrans also disables pf state. That is, one of 1729 + both pf_enable and pf_retrans > path_max_retrans can disable pf state. 1730 + Since pf_retrans and path_max_retrans can be changed by userspace 1731 + application, sometimes user expects to disable pf state by the value of 1732 + pf_retrans > path_max_retrans, but occasionally the value of pf_retrans 1733 + or path_max_retrans is changed by the user application, this pf state is 1734 + enabled. As such, it is necessary to add this to dynamically enable 1735 + and disable pf state. See: 1736 + https://datatracker.ietf.org/doc/draft-ietf-tsvwg-sctp-failover for 1737 + details. 1738 + 1739 + 1: Enable pf. 1740 + 1741 + 0: Disable pf. 1742 + 1743 + Default: 1 1744 + 1726 1745 addip_noauth_enable - BOOLEAN 1727 1746 Dynamic Address Reconfiguration (ADD-IP) requires the use of 1728 1747 authentication to protect the operations of adding or removing new ··· 1818 1799 having to reduce path_max_retrans to a very low value. See: 1819 1800 http://www.ietf.org/id/draft-nishida-tsvwg-sctp-failover-05.txt 1820 1801 for details. Note also that a value of pf_retrans > path_max_retrans 1821 - disables this feature 1802 + disables this feature. Since both pf_retrans and path_max_retrans can 1803 + be changed by userspace application, a variable pf_enable is used to 1804 + disable pf state. 1822 1805 1823 1806 Default: 0 1824 1807
+7
include/net/netns/sctp.h
··· 89 89 int pf_retrans; 90 90 91 91 /* 92 + * Disable Potentially-Failed feature, the feature is enabled by default 93 + * pf_enable - 0 : disable pf 94 + * - >0 : enable pf 95 + */ 96 + int pf_enable; 97 + 98 + /* 92 99 * Policy for preforming sctp/socket accounting 93 100 * 0 - do socket level accounting, all assocs share sk_sndbuf 94 101 * 1 - do sctp accounting, each asoc may use sk_sndbuf bytes
+3
net/sctp/protocol.c
··· 1223 1223 /* Max.Burst - 4 */ 1224 1224 net->sctp.max_burst = SCTP_DEFAULT_MAX_BURST; 1225 1225 1226 + /* Enable pf state by default */ 1227 + net->sctp.pf_enable = 1; 1228 + 1226 1229 /* Association.Max.Retrans - 10 attempts 1227 1230 * Path.Max.Retrans - 5 attempts (per destination address) 1228 1231 * Max.Init.Retransmits - 8 attempts
+4 -1
net/sctp/sm_sideeffect.c
··· 477 477 struct sctp_transport *transport, 478 478 int is_hb) 479 479 { 480 + struct net *net = sock_net(asoc->base.sk); 481 + 480 482 /* The check for association's overall error counter exceeding the 481 483 * threshold is done in the state function. 482 484 */ ··· 505 503 * is SCTP_ACTIVE, then mark this transport as Partially Failed, 506 504 * see SCTP Quick Failover Draft, section 5.1 507 505 */ 508 - if ((transport->state == SCTP_ACTIVE) && 506 + if (net->sctp.pf_enable && 507 + (transport->state == SCTP_ACTIVE) && 509 508 (asoc->pf_retrans < transport->pathmaxrxt) && 510 509 (transport->error_count > asoc->pf_retrans)) { 511 510
+7
net/sctp/sysctl.c
··· 308 308 .extra1 = &max_autoclose_min, 309 309 .extra2 = &max_autoclose_max, 310 310 }, 311 + { 312 + .procname = "pf_enable", 313 + .data = &init_net.sctp.pf_enable, 314 + .maxlen = sizeof(int), 315 + .mode = 0644, 316 + .proc_handler = proc_dointvec, 317 + }, 311 318 312 319 { /* sentinel */ } 313 320 };