Index: sys/netinet/ip_carp.c =================================================================== RCS file: /cvsroot/src/sys/netinet/ip_carp.c,v retrieving revision 1.117 retrieving revision 1.120 diff -p -u -r1.117 -r1.120 --- sys/netinet/ip_carp.c 2 Sep 2022 23:48:11 -0000 1.117 +++ sys/netinet/ip_carp.c 1 Aug 2023 07:04:16 -0000 1.120 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.117 2022/09/02 23:48:11 thorpej Exp $ */ +/* $NetBSD: ip_carp.c,v 1.120 2023/08/01 07:04:16 mrg Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -33,7 +33,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.117 2022/09/02 23:48:11 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.120 2023/08/01 07:04:16 mrg Exp $"); /* * TODO: @@ -186,10 +186,10 @@ struct carp_if { } static void carp_hmac_prepare(struct carp_softc *); -static void carp_hmac_generate(struct carp_softc *, u_int32_t *, - unsigned char *); -static int carp_hmac_verify(struct carp_softc *, u_int32_t *, - unsigned char *); +static void carp_hmac_generate(struct carp_softc *, u_int32_t[2], + unsigned char[20]); +static int carp_hmac_verify(struct carp_softc *, u_int32_t[2], + unsigned char[20]); static void carp_setroute(struct carp_softc *, int); static void carp_proto_input_c(struct mbuf *, struct carp_header *, sa_family_t); @@ -1091,6 +1091,8 @@ carp_send_ad(void *v) _s = pserialize_read_enter(); ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev); if (ifa == NULL) + ifa = ifaof_ifpforaddr(&sa, &sc->sc_if); + if (ifa == NULL) ip->ip_src.s_addr = 0; else ip->ip_src.s_addr = @@ -1142,6 +1144,7 @@ carp_send_ad(void *v) if (sc->sc_naddrs6) { struct ip6_hdr *ip6; struct ifaddr *ifa; + struct ifnet *ifp; int _s; MGETHDR(m, M_DONTWAIT, MT_HEADER); @@ -1168,7 +1171,12 @@ carp_send_ad(void *v) memset(&sa, 0, sizeof(sa)); sa.sa_family = AF_INET6; _s = pserialize_read_enter(); - ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev); + ifp = sc->sc_carpdev; + ifa = ifaof_ifpforaddr(&sa, ifp); + if (ifa == NULL) { /* This should never happen with IPv6 */ + ifp = &sc->sc_if; + ifa = ifaof_ifpforaddr(&sa, ifp); + } if (ifa == NULL) /* This should never happen with IPv6 */ memset(&ip6->ip6_src, 0, sizeof(struct in6_addr)); else @@ -1179,7 +1187,7 @@ carp_send_ad(void *v) ip6->ip6_dst.s6_addr16[0] = htons(0xff02); ip6->ip6_dst.s6_addr8[15] = 0x12; - if (in6_setscope(&ip6->ip6_dst, &sc->sc_if, NULL) != 0) { + if (in6_setscope(&ip6->ip6_dst, ifp, NULL) != 0) { if_statinc(&sc->sc_if, if_oerrors); m_freem(m); CARP_LOG(sc, ("in6_setscope failed")); @@ -1876,6 +1884,9 @@ carp_join_multicast(struct carp_softc *s struct ip_moptions *imo = &sc->sc_imo, tmpimo; struct in_addr addr; + if (sc->sc_carpdev == NULL) + return (ENETDOWN); + memset(&tmpimo, 0, sizeof(tmpimo)); addr.s_addr = INADDR_CARP_GROUP; if ((tmpimo.imo_membership[0] = @@ -1885,7 +1896,7 @@ carp_join_multicast(struct carp_softc *s imo->imo_membership[0] = tmpimo.imo_membership[0]; imo->imo_num_memberships = 1; - imo->imo_multicast_if_index = sc->sc_if.if_index; + imo->imo_multicast_if_index = sc->sc_carpdev->if_index; imo->imo_multicast_ttl = CARP_DFLTTL; imo->imo_multicast_loop = 0; return (0); @@ -1970,6 +1981,9 @@ carp_join_multicast6(struct carp_softc * struct sockaddr_in6 addr6; int error; + if (sc->sc_carpdev == NULL) + return (ENETDOWN); + /* Join IPv6 CARP multicast group */ memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; @@ -1996,7 +2010,7 @@ carp_join_multicast6(struct carp_softc * } /* apply v6 multicast membership */ - im6o->im6o_multicast_if_index = sc->sc_if.if_index; + im6o->im6o_multicast_if_index = sc->sc_carpdev->if_index; if (imm) LIST_INSERT_HEAD(&im6o->im6o_memberships, imm, i6mm_chain); Index: sys/netinet/ip_output.c =================================================================== RCS file: /cvsroot/src/sys/netinet/ip_output.c,v retrieving revision 1.324.2.1 retrieving revision 1.326 diff -p -u -r1.324.2.1 -r1.326 --- sys/netinet/ip_output.c 25 Apr 2023 16:15:14 -0000 1.324.2.1 +++ sys/netinet/ip_output.c 19 Apr 2023 22:00:18 -0000 1.326 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_output.c,v 1.324.2.1 2023/04/25 16:15:14 martin Exp $ */ +/* $NetBSD: ip_output.c,v 1.326 2023/04/19 22:00:18 mlelstv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.324.2.1 2023/04/25 16:15:14 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.326 2023/04/19 22:00:18 mlelstv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -348,11 +348,6 @@ ip_output(struct mbuf *m0, struct mbuf * } mtu = ifp->if_mtu; ia = in_get_ia_from_ifp_psref(ifp, &psref_ia); - if (ia == NULL) { - IP_STATINC(IP_STAT_IFNOADDR); - error = EADDRNOTAVAIL; - goto bad; - } if (IN_MULTICAST(ip->ip_dst.s_addr) || ip->ip_dst.s_addr == INADDR_BROADCAST) { isbroadcast = 0;