Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_vxlan.c
Show First 20 Lines • Show All 1,621 Lines • ▼ Show 20 Lines | vxlan_setup_interface_hdrlen(struct vxlan_softc *sc) | ||||
ifp = sc->vxl_ifp; | ifp = sc->vxl_ifp; | ||||
ifp->if_hdrlen = ETHER_HDR_LEN + sizeof(struct vxlanudphdr); | ifp->if_hdrlen = ETHER_HDR_LEN + sizeof(struct vxlanudphdr); | ||||
if (VXLAN_SOCKADDR_IS_IPV4(&sc->vxl_dst_addr) != 0) | if (VXLAN_SOCKADDR_IS_IPV4(&sc->vxl_dst_addr) != 0) | ||||
ifp->if_hdrlen += sizeof(struct ip); | ifp->if_hdrlen += sizeof(struct ip); | ||||
else if (VXLAN_SOCKADDR_IS_IPV6(&sc->vxl_dst_addr) != 0) | else if (VXLAN_SOCKADDR_IS_IPV6(&sc->vxl_dst_addr) != 0) | ||||
ifp->if_hdrlen += sizeof(struct ip6_hdr); | ifp->if_hdrlen += sizeof(struct ip6_hdr); | ||||
ifp->if_mtu -= ifp->if_hdrlen; | |||||
} | } | ||||
static int | static int | ||||
vxlan_valid_init_config(struct vxlan_softc *sc) | vxlan_valid_init_config(struct vxlan_softc *sc) | ||||
{ | { | ||||
const char *reason; | const char *reason; | ||||
if (vxlan_check_vni(sc->vxl_vni) != 0) { | if (vxlan_check_vni(sc->vxl_vni) != 0) { | ||||
▲ Show 20 Lines • Show All 1,569 Lines • ▼ Show 20 Lines | vxlan_clone_create(struct if_clone *ifc, int unit, caddr_t params) | ||||
ifmedia_add(&sc->vxl_media, IFM_ETHER | IFM_AUTO, 0, NULL); | ifmedia_add(&sc->vxl_media, IFM_ETHER | IFM_AUTO, 0, NULL); | ||||
ifmedia_set(&sc->vxl_media, IFM_ETHER | IFM_AUTO); | ifmedia_set(&sc->vxl_media, IFM_ETHER | IFM_AUTO); | ||||
ether_gen_addr(ifp, &sc->vxl_hwaddr); | ether_gen_addr(ifp, &sc->vxl_hwaddr); | ||||
ether_ifattach(ifp, sc->vxl_hwaddr.octet); | ether_ifattach(ifp, sc->vxl_hwaddr.octet); | ||||
ifp->if_baudrate = 0; | ifp->if_baudrate = 0; | ||||
vxlan_setup_interface_hdrlen(sc); | vxlan_setup_interface_hdrlen(sc); | ||||
kib: Note that at this point ifp is externally visible already. Doing vxlan_setup_interface_hdrlen… | |||||
return (0); | return (0); | ||||
fail: | fail: | ||||
free(sc, M_VXLAN); | free(sc, M_VXLAN); | ||||
return (error); | return (error); | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 418 Lines • Show Last 20 Lines |
Note that at this point ifp is externally visible already. Doing vxlan_setup_interface_hdrlen() there without the lock is simply unsafe since other thread might start modifying this vxlan parameters.