Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/net Pull up following revision(s) (requested by ozaki...



details:   https://anonhg.NetBSD.org/src/rev/0fcd67a20c85
branches:  netbsd-8
changeset: 435101:0fcd67a20c85
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jul 10 14:41:31 2018 +0000

description:
Pull up following revision(s) (requested by ozaki-r in ticket #918):

        sys/net/if_llatbl.c: revision 1.28

Don't overwrite an existing llentry on RTM_ADD to avoid race conditions
Reported and tested by christos@

diffstat:

 sys/net/if_llatbl.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 270776c3ca7c -r 0fcd67a20c85 sys/net/if_llatbl.c
--- a/sys/net/if_llatbl.c       Tue Jul 03 07:13:41 2018 +0000
+++ b/sys/net/if_llatbl.c       Tue Jul 10 14:41:31 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_llatbl.c,v 1.18.6.4 2018/06/09 14:44:33 martin Exp $        */
+/*     $NetBSD: if_llatbl.c,v 1.18.6.5 2018/07/10 14:41:31 martin Exp $        */
 /*
  * Copyright (c) 2004 Luigi Rizzo, Alessandro Cerri. All rights reserved.
  * Copyright (c) 2004-2008 Qing Li. All rights reserved.
@@ -677,7 +677,7 @@
 
                /* Add static LLE */
                IF_AFDATA_WLOCK(ifp);
-               lle = lla_lookup(llt, 0, dst);
+               lle = lla_lookup(llt, LLE_EXCLUSIVE, dst);
 
                /* Cannot overwrite an existing static entry */
                if (lle != NULL &&
@@ -689,8 +689,18 @@
                        error = EEXIST;
                        goto out;
                }
-               if (lle != NULL)
-                       LLE_RUNLOCK(lle);
+
+               /*
+                * We can't overwrite an existing entry to avoid race
+                * conditions so remove it first.
+                */
+               if (lle != NULL) {
+                       size_t pkts_dropped = llentry_free(lle);
+                       if (dst->sa_family == AF_INET) {
+                               arp_stat_add(ARP_STAT_DFRDROPPED,
+                                   (uint64_t)pkts_dropped);
+                       }
+               }
 
                lle = lla_create(llt, 0, dst, rt);
                if (lle == NULL) {



Home | Main Index | Thread Index | Old Index