Default: 0
 
+ps_retrans - INTEGER
+       Primary.Switchover.Max.Retrans (PSMR), it's a tunable parameter coming
+       from section-5 "Primary Path Switchover" in rfc7829.  The primary path
+       will be changed to another active path when the path error counter on
+       the old primary path exceeds PSMR, so that "the SCTP sender is allowed
+       to continue data transmission on a new working path even when the old
+       primary destination address becomes active again".   Note this feature
+       is disabled by initializing 'ps_retrans' per netns as 0xffff by default,
+       and its value can't be less than 'pf_retrans' when changing by sysctl.
+
+       Default: 0xffff
+
 rto_initial - INTEGER
        The initial round trip timeout value in milliseconds that will be used
        in calculating round trip times.  This is the initial time interval
 
         */
        int pf_retrans;
 
+       /* Primary.Switchover.Max.Retrans sysctl value
+        * taken from:
+        * https://tools.ietf.org/html/rfc7829
+        */
+       int ps_retrans;
+
        /*
         * Disable Potentially-Failed feature, the feature is enabled by default
         * pf_enable    -  0  : disable pf
 
 };
 #define SCTP_PF_EXPOSE_MAX     SCTP_PF_EXPOSE_ENABLE
 
+#define SCTP_PS_RETRANS_MAX    0xffff
+
 /* These return values describe the success or failure of a number of
  * routines which form the lower interface to SCTP_outqueue.
  */
 
        __u32 flowlabel;
        __u8  dscp;
 
-       int pf_retrans;
+       __u16 pf_retrans;
+       __u16 ps_retrans;
 
        /* The initial Path MTU to use for new associations. */
        __u32 pathmtu;
         * and will be initialized from the assocs value.  This can be changed
         * using the SCTP_PEER_ADDR_THLDS socket option
         */
-       int pf_retrans;
+       __u16 pf_retrans;
+       /* Used for primary path switchover. */
+       __u16 ps_retrans;
        /* PMTU       : The current known path MTU.  */
        __u32 pathmtu;
 
         * and will be initialized from the assocs value.  This can be
         * changed using the SCTP_PEER_ADDR_THLDS socket option
         */
-       int pf_retrans;
+       __u16 pf_retrans;
+       /* Used for primary path switchover. */
+       __u16 ps_retrans;
 
        /* Maximum number of times the endpoint will retransmit INIT  */
        __u16 max_init_attempts;
 
         */
        asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
        asoc->pf_retrans  = sp->pf_retrans;
+       asoc->ps_retrans  = sp->ps_retrans;
        asoc->pf_expose   = sp->pf_expose;
 
        asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
 
        /* And the partial failure retrans threshold */
        peer->pf_retrans = asoc->pf_retrans;
+       /* And the primary path switchover retrans threshold */
+       peer->ps_retrans = asoc->ps_retrans;
 
        /* Initialize the peer's SACK delay timeout based on the
         * association configured value.
 
        /* Max.Burst                - 4 */
        net->sctp.max_burst                     = SCTP_DEFAULT_MAX_BURST;
 
+       /* Disable of Primary Path Switchover by default */
+       net->sctp.ps_retrans = SCTP_PS_RETRANS_MAX;
+
        /* Enable pf state by default */
        net->sctp.pf_enable = 1;
 
 
                                             SCTP_FAILED_THRESHOLD);
        }
 
+       if (transport->error_count > transport->ps_retrans &&
+           asoc->peer.primary_path == transport &&
+           asoc->peer.active_path != transport)
+               sctp_assoc_set_primary(asoc, asoc->peer.active_path);
+
        /* E2) For the destination address for which the timer
         * expires, set RTO <- RTO * 2 ("back off the timer").  The
         * maximum value discussed in rule C7 above (RTO.max) may be
 
        sp->hbinterval  = net->sctp.hb_interval;
        sp->pathmaxrxt  = net->sctp.max_retrans_path;
        sp->pf_retrans  = net->sctp.pf_retrans;
+       sp->ps_retrans  = net->sctp.ps_retrans;
        sp->pf_expose   = net->sctp.pf_expose;
        sp->pathmtu     = 0; /* allow default discovery */
        sp->sackdelay   = net->sctp.sack_timeout;
 
 static int rto_alpha_max = 1000;
 static int rto_beta_max = 1000;
 static int pf_expose_max = SCTP_PF_EXPOSE_MAX;
+static int ps_retrans_max = SCTP_PS_RETRANS_MAX;
 
 static unsigned long max_autoclose_min = 0;
 static unsigned long max_autoclose_max =
                .mode           = 0644,
                .proc_handler   = proc_dointvec_minmax,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = SYSCTL_INT_MAX,
+               .extra2         = &init_net.sctp.ps_retrans,
+       },
+       {
+               .procname       = "ps_retrans",
+               .data           = &init_net.sctp.ps_retrans,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_minmax,
+               .extra1         = &init_net.sctp.pf_retrans,
+               .extra2         = &ps_retrans_max,
        },
        {
                .procname       = "sndbuf_policy",