Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Only set the IPv4 address in umb(4) if both MBIM...



details:   https://anonhg.NetBSD.org/src/rev/360041076ad7
branches:  trunk
changeset: 970288:360041076ad7
user:      khorben <khorben%NetBSD.org@localhost>
date:      Thu Mar 19 07:51:22 2020 +0000

description:
Only set the IPv4 address in umb(4) if both MBIM_IPCONF_HAS_ADDRINFO and
MBIM_IPCONF_HAS_GWINFO are available. Configuring umb(4) without gateway
wont work the system needs a destination address for the interface.
Problem found by jsg@.
OK jsg@ deraadt@

>From OpenBSD.

diffstat:

 sys/dev/usb/if_umb.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (41 lines):

diff -r ae125a6e5bd3 -r 360041076ad7 sys/dev/usb/if_umb.c
--- a/sys/dev/usb/if_umb.c      Thu Mar 19 07:50:27 2020 +0000
+++ b/sys/dev/usb/if_umb.c      Thu Mar 19 07:51:22 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_umb.c,v 1.16 2020/03/19 07:50:27 khorben Exp $ */
+/*     $NetBSD: if_umb.c,v 1.17 2020/03/19 07:51:22 khorben Exp $ */
 /*     $OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */
 
 /*
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.16 2020/03/19 07:50:27 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.17 2020/03/19 07:51:22 khorben Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1714,7 +1714,8 @@
         * IPv4 configuration
         */
        avail = le32toh(ic->ipv4_available);
-       if (avail & MBIM_IPCONF_HAS_ADDRINFO) {
+       if ((avail & (MBIM_IPCONF_HAS_ADDRINFO | MBIM_IPCONF_HAS_GWINFO)) ==
+           (MBIM_IPCONF_HAS_ADDRINFO | MBIM_IPCONF_HAS_GWINFO)) {
                n = le32toh(ic->ipv4_naddr);
                off = le32toh(ic->ipv4_addroffs);
 
@@ -1734,10 +1735,8 @@
                sin = (struct sockaddr_in *)&ifra.ifra_dstaddr;
                sin->sin_family = AF_INET;
                sin->sin_len = sizeof(ifra.ifra_dstaddr);
-               if (avail & MBIM_IPCONF_HAS_GWINFO) {
-                       off = le32toh(ic->ipv4_gwoffs);
-                       sin->sin_addr.s_addr = *((uint32_t *)((char *)data + off));
-               }
+               off = le32toh(ic->ipv4_gwoffs);
+               sin->sin_addr.s_addr = *((uint32_t *)((char *)data + off));
 
                sin = (struct sockaddr_in *)&ifra.ifra_mask;
                sin->sin_family = AF_INET;



Home | Main Index | Thread Index | Old Index