Module Name: src
Committed By: rin
Date: Fri Dec 20 00:49:08 UTC 2024
Modified Files:
src/sys/netinet: ip_carp.c
Log Message:
carp_join_multicast: Stop allocating ip_moptions on stack
It was just a waste of memory. NFC otherwise, and no regression
observed for full ATF run on amd64.
Partially taken from OpenBSD:
https://github.com/openbsd/src/commit/1f237790b75
XXX
Seems like OpenBSD has some fixes to carp, that may improve our
implementation...
To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/netinet/ip_carp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.120 src/sys/netinet/ip_carp.c:1.121
--- src/sys/netinet/ip_carp.c:1.120 Tue Aug 1 07:04:16 2023
+++ src/sys/netinet/ip_carp.c Fri Dec 20 00:49:08 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_carp.c,v 1.120 2023/08/01 07:04:16 mrg Exp $ */
+/* $NetBSD: ip_carp.c,v 1.121 2024/12/20 00:49:08 rin Exp $ */
/* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */
/*
@@ -33,7 +33,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.120 2023/08/01 07:04:16 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.121 2024/12/20 00:49:08 rin Exp $");
/*
* TODO:
@@ -1881,20 +1881,18 @@ carp_set_addr(struct carp_softc *sc, str
static int
carp_join_multicast(struct carp_softc *sc)
{
- struct ip_moptions *imo = &sc->sc_imo, tmpimo;
+ struct ip_moptions *imo = &sc->sc_imo;
+ struct in_multi *imm;
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] =
- in_addmulti(&addr, &sc->sc_if)) == NULL) {
+ if ((imm = in_addmulti(&addr, &sc->sc_if)) == NULL)
return (ENOBUFS);
- }
- imo->imo_membership[0] = tmpimo.imo_membership[0];
+ imo->imo_membership[0] = imm;
imo->imo_num_memberships = 1;
imo->imo_multicast_if_index = sc->sc_carpdev->if_index;
imo->imo_multicast_ttl = CARP_DFLTTL;