From: jmatthew Date: Tue, 24 Oct 2023 09:13:22 +0000 (+0000) Subject: Delete any existing v4 address before setting a new one. This allows us X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=32a3b737c688653ed1bf72bda187b7a17148be27;p=openbsd 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@ --- 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 @@ -1814,6 +1814,14 @@ umb_add_inet_config(struct umb_softc *sc, struct in_addr ip, u_int prefixlen, struct rtentry *rt; 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;