Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Drop early if there's no PPPoE interface. Otherwise ...



details:   https://anonhg.NetBSD.org/src/rev/d80b7e00fca7
branches:  trunk
changeset: 322454:d80b7e00fca7
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu May 03 16:52:42 2018 +0000

description:
Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.

diffstat:

 sys/net/if_pppoe.c |  20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diffs (52 lines):

diff -r d08094c93e14 -r d80b7e00fca7 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Thu May 03 15:47:36 2018 +0000
+++ b/sys/net/if_pppoe.c        Thu May 03 16:52:42 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.136 2018/04/18 07:40:40 knakahara Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.137 2018/05/03 16:52:42 maxv Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.136 2018/04/18 07:40:40 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.137 2018/05/03 16:52:42 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -944,13 +944,16 @@
 static void
 pppoe_disc_input(struct mbuf *m)
 {
+       KASSERT(m->m_flags & M_PKTHDR);
 
-       /* avoid error messages if there is not a single pppoe instance */
+       /*
+        * Avoid error messages if there is not a single PPPoE instance.
+        */
        if (!LIST_EMPTY(&pppoe_softc_list)) {
-               KASSERT(m->m_flags & M_PKTHDR);
                pppoe_dispatch_disc_pkt(m, 0);
-       } else
+       } else {
                m_freem(m);
+       }
 }
 
 static bool
@@ -977,6 +980,13 @@
 
        KASSERT(m->m_flags & M_PKTHDR);
 
+       /*
+        * Avoid error messages if there is not a single PPPoE instance.
+        */
+       if (LIST_EMPTY(&pppoe_softc_list)) {
+               goto drop;
+       }
+
        if (term_unknown) {
                memcpy(shost, mtod(m, struct ether_header*)->ether_shost,
                    ETHER_ADDR_LEN);



Home | Main Index | Thread Index | Old Index