On 2015/09/30 00:31, Stuart Henderson wrote:
> This diff teachs sppp/pppoe(4) to set ifq priority on control frames
> (LCP, PAP/CHAP, the various pppoe PADx). These cannot be set the normal
> way because these non-IP frames aren't fed through PF.
> 
> It's done using a #define which is currently set to a high priority as
> that's what is normally wanted to avoid control packets being dropped on
> a busy link (too many missed LCP echoes and the link is likely to be
> torn down). AFAICT this is also what cisco are now doing by default;
> http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/bbdsl/configuration/xe-3s/asr1000/bba-xe-3s-asr1000-book/bba-cos-ppp-pppoe-xe.html#GUID-1B5EEC89-1EDF-459A-A097-22C867B12969
> 
> This is connected with the VLAN priority problem mentioned in
> https://marc.info/?l=openbsd-misc&m=139889217231865&w=2 and
> https://marc.info/?l=openbsd-misc&m=142920873204434&w=2 but isn't
> a direct fix (though people who are recompiling to avoid that problem
> could use this with a different value than 7, plus a PF rule - that
> would allow ifq to work normally on interfaces not involved with pppoe).
> 
> Any comments?

Updated, previous diff no longer applies.

Index: if_sppp.h
===================================================================
RCS file: /cvs/src/sys/net/if_sppp.h,v
retrieving revision 1.21
diff -u -p -r1.21 if_sppp.h
--- if_sppp.h   30 Sep 2015 09:45:20 -0000      1.21
+++ if_sppp.h   30 Sep 2015 12:20:15 -0000
@@ -56,6 +56,7 @@ enum ppp_phase {
 
 #define AUTHMAXLEN     256     /* including terminating '\0' */
 #define AUTHCHALEN     16      /* length of the challenge we send */
+#define SPPPCTL_IFQ_PRIO 7     /* priority for control frames */
 
 /*
  * Definitions to pass struct sppp data down into the kernel using the
Index: if_spppsubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_spppsubr.c,v
retrieving revision 1.139
diff -u -p -r1.139 if_spppsubr.c
--- if_spppsubr.c       30 Sep 2015 12:19:34 -0000      1.139
+++ if_spppsubr.c       30 Sep 2015 12:20:15 -0000
@@ -994,6 +994,7 @@ sppp_cp_send(struct sppp *sp, u_short pr
                return;
        m->m_pkthdr.len = m->m_len = pkthdrlen + LCP_HEADER_LEN + len;
        m->m_pkthdr.ph_ifidx = 0;
+       m->m_pkthdr.pf.prio = SPPPCTL_IFQ_PRIO;
 
        if (sp->pp_flags & PP_NOFRAMING) {
                *mtod(m, u_int16_t *) = htons(proto);
@@ -4081,6 +4082,7 @@ sppp_auth_send(const struct cp *cp, stru
        if (! m)
                return;
        m->m_pkthdr.ph_ifidx = 0;
+       m->m_pkthdr.pf.prio = SPPPCTL_IFQ_PRIO;
 
        if (sp->pp_flags & PP_NOFRAMING) {
                *mtod(m, u_int16_t *) = htons(cp->proto);
Index: if_pppoe.c
===================================================================
RCS file: /cvs/src/sys/net/if_pppoe.c,v
retrieving revision 1.48
diff -u -p -r1.48 if_pppoe.c
--- if_pppoe.c  13 Sep 2015 17:53:44 -0000      1.48
+++ if_pppoe.c  30 Sep 2015 12:20:15 -0000
@@ -1077,6 +1077,8 @@ pppoe_send_padi(struct pppoe_softc *sc)
        if (m0 == NULL)
                return (ENOBUFS);
 
+       m0->m_pkthdr.pf.prio = SPPPCTL_IFQ_PRIO;
+
        /* fill in pkt */
        p = mtod(m0, u_int8_t *);
        PPPOE_ADD_HEADER(p, PPPOE_CODE_PADI, 0, len);
@@ -1314,6 +1316,8 @@ pppoe_send_padr(struct pppoe_softc *sc)
        if (m0 == NULL)
                return (ENOBUFS);
 
+       m0->m_pkthdr.pf.prio = SPPPCTL_IFQ_PRIO;
+
        p = mtod(m0, u_int8_t *);
        PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, len);
        PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
@@ -1370,6 +1374,8 @@ pppoe_send_padt(struct ifnet *outgoing_i
        if (m0 == NULL)
                return (ENOBUFS);
 
+       m0->m_pkthdr.pf.prio = SPPPCTL_IFQ_PRIO;
+
        p = mtod(m0, u_int8_t *);
        PPPOE_ADD_HEADER(p, PPPOE_CODE_PADT, session, 0);
 
@@ -1409,6 +1415,8 @@ pppoe_send_pado(struct pppoe_softc *sc)
        if (m0 == NULL)
                return (ENOBUFS);
 
+       m0->m_pkthdr.pf.prio = SPPPCTL_IFQ_PRIO;
+
        p = mtod(m0, u_int8_t *);
        PPPOE_ADD_HEADER(p, PPPOE_CODE_PADO, 0, len);
        PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE);
@@ -1447,6 +1455,8 @@ pppoe_send_pads(struct pppoe_softc *sc)
        m0 = pppoe_get_mbuf(len + PPPOE_HEADERLEN);
        if (m0 == NULL)
                return (ENOBUFS);
+
+       m0->m_pkthdr.pf.prio = SPPPCTL_IFQ_PRIO;
 
        p = mtod(m0, u_int8_t *);
        PPPOE_ADD_HEADER(p, PPPOE_CODE_PADS, sc->sc_session, len);

Reply via email to