Bug 284140 - ifconfig carp : unicast switch back to multicast when not specifying peer
Summary: ifconfig carp : unicast switch back to multicast when not specifying peer
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.2-RELEASE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-net (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-18 18:05 UTC by johan
Modified: 2025-01-24 10:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description johan 2025-01-18 18:05:26 UTC
Using carp in unicast, changing any other attribute than "peer" switch back to unicast :

root@testvip1:~ # ifconfig epair0b
epair0b: flags=1008943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 9000
        options=8<VLAN_MTU>
        ether 2c:44:fd:19:94:db
        hwaddr 02:03:7f:1f:e6:0b
        inet 192.168.1.83 netmask 0xffffff00 broadcast 192.168.1.255
        inet 192.168.1.85 netmask 0xffffff00 broadcast 192.168.1.255 vhid 99
        groups: epair
        carp: BACKUP vhid 99 advbase 1 advskew 150
              peer 192.168.1.84 peer6 ff02::12
        media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@testvip1:~ # ifconfig epair0b vhid 99 advskew 50
root@testvip1:~ # ifconfig epair0b
epair0b: flags=1008943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 9000
        options=8<VLAN_MTU>
        ether 2c:44:fd:19:94:db
        hwaddr 02:03:7f:1f:e6:0b
        inet 192.168.1.83 netmask 0xffffff00 broadcast 192.168.1.255
        inet 192.168.1.85 netmask 0xffffff00 broadcast 192.168.1.255 vhid 99
        groups: epair
        carp: MASTER vhid 99 advbase 1 advskew 50
              peer 224.0.0.18 peer6 ff02::12
        media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

This is caused by multicast set as default in carp_ctor in sbin/ifconfig/carp.c, so when setcarp_callback run it sets carpr.carpr_addr back to 224.0.0.18.

On my setup, commenting default values works like assumed, and first initialization also correctly set peer to 224.0.0.18 if not specified by ifconfig.

Maybe these default values could be removed ?

iff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c
index dd09838b5d8b..ef24b0899fe7 100644
--- a/sbin/ifconfig/carp.c
+++ b/sbin/ifconfig/carp.c
@@ -246,10 +264,6 @@ static struct afswtch af_carp = {
 static __constructor void
 carp_ctor(void)
 {
-       /* Default to multicast. */
-       setcarp_mcast(NULL, NULL, 0);
-       setcarp_mcast6(NULL, NULL, 0);
-
        for (size_t i = 0; i < nitems(carp_cmds);  i++)
                cmd_register(&carp_cmds[i]);
        af_register(&af_carp);
Comment 1 commit-hook freebsd_committer freebsd_triage 2025-01-24 10:26:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=af33f86e6aef6b15c8aa3da615167272aa7a3ee3

commit af33f86e6aef6b15c8aa3da615167272aa7a3ee3
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-01-21 09:49:55 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-01-24 10:20:30 +0000

    carp: don't unintentionally revert to multicast mode

    PR:             284140
    MFC after:      2 weeks
    Sponsored by:   Rubicon Communications, LLC ("Netgate")

 sbin/ifconfig/carp.c      | 4 ----
 tests/sys/netinet/carp.sh | 7 +++++--
 2 files changed, 5 insertions(+), 6 deletions(-)