summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorJonathan Matthew <jmatthew@cvs.openbsd.org>2023-10-24 09:13:23 +0000
committerJonathan Matthew <jmatthew@cvs.openbsd.org>2023-10-24 09:13:23 +0000
commit9eef72e355f09c6f57da29f528189920d4871325 (patch)
treedb973eae150d871e38a15b3034ae2d0a2a6dc656 /sys/dev/usb
parent2ef84e80ede52749a9ec53429077905363dd8bcc (diff)
Delete any existing v4 address before setting a new one. This allows us
to keep a working default route when the address changes. ok dlg@ kn@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/if_umb.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/dev/usb/if_umb.c b/sys/dev/usb/if_umb.c
index 46ecb684241..0d0c2c4716f 100644
--- a/sys/dev/usb/if_umb.c
+++ b/sys/dev/usb/if_umb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_umb.c,v 1.55 2023/09/01 20:24:29 mvs Exp $ */
+/* $OpenBSD: if_umb.c,v 1.56 2023/10/24 09:13:22 jmatthew Exp $ */
/*
* Copyright (c) 2016 genua mbH
@@ -1815,6 +1815,14 @@ umb_add_inet_config(struct umb_softc *sc, struct in_addr ip, u_int prefixlen,
int rv;
memset(&ifra, 0, sizeof (ifra));
+ rv = in_ioctl(SIOCDIFADDR, (caddr_t)&ifra, ifp, 1);
+ if (rv != 0 && rv != EADDRNOTAVAIL) {
+ printf("%s: unable to delete IPv4 address, error %d\n",
+ DEVNAM(ifp->if_softc), rv);
+ return rv;
+ }
+
+ memset(&ifra, 0, sizeof (ifra));
sin = &ifra.ifra_addr;
sin->sin_family = AF_INET;
sin->sin_len = sizeof (*sin);