HomeFreeBSD

carp: fix mbuf_tag usage in carp_macmatch6

Description

carp: fix mbuf_tag usage in carp_macmatch6

carp_macmatch6() had two issues that affect IPv6 processing:

  1. it returns sc->sc_addr pointer that might become invalid after softc destroying.
  2. carp_output() expects carp vhid to be stored in the mtag, not the pointer to softc.

Fix these issues. Allocate enough space in mtag to keep both vhid and
mac address. Copy vhid first to fix issue with carp_output(), then
copy sc_addr and return pointer to this copy. mtag will be alive
until mbuf is used.
This fixes problem when IPv6 packets originated from CARP IPv6 address
use incorrect mac address due to mbuf_tag has invalid data.

Reviewed by: zlei, kp, glebius
Obtained from: Yandex LLC
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D50455

Details

Provenance
aeAuthored on May 24 2025, 8:18 AM
Reviewer
zlei
Differential Revision
D50455: carp: fix mbuf_tag usage in carp_macmatch6
Parents
rG9c2001036185: share/mk: pass SHARED_CFLAGS to PIC and PIE from assembly
Branches
Unknown
Tags
Unknown