Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_vxlan.c
| Show First 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | static int vxlan_encap6(struct vxlan_softc *, | ||||
| const union vxlan_sockaddr *, struct mbuf *); | const union vxlan_sockaddr *, struct mbuf *); | ||||
| static int vxlan_transmit(struct ifnet *, struct mbuf *); | static int vxlan_transmit(struct ifnet *, struct mbuf *); | ||||
| static void vxlan_qflush(struct ifnet *); | static void vxlan_qflush(struct ifnet *); | ||||
| static bool vxlan_rcv_udp_packet(struct mbuf *, int, struct inpcb *, | static bool vxlan_rcv_udp_packet(struct mbuf *, int, struct inpcb *, | ||||
| const struct sockaddr *, void *); | const struct sockaddr *, void *); | ||||
| static int vxlan_input(struct vxlan_socket *, uint32_t, struct mbuf **, | static int vxlan_input(struct vxlan_socket *, uint32_t, struct mbuf **, | ||||
| const struct sockaddr *); | const struct sockaddr *); | ||||
| static int vxlan_stats_alloc(struct vxlan_softc *); | static void vxlan_stats_alloc(struct vxlan_softc *); | ||||
| static void vxlan_stats_free(struct vxlan_softc *); | static void vxlan_stats_free(struct vxlan_softc *); | ||||
| static void vxlan_set_default_config(struct vxlan_softc *); | static void vxlan_set_default_config(struct vxlan_softc *); | ||||
| static int vxlan_set_user_config(struct vxlan_softc *, | static int vxlan_set_user_config(struct vxlan_softc *, | ||||
| struct ifvxlanparam *); | struct ifvxlanparam *); | ||||
| static int vxlan_set_reqcap(struct vxlan_softc *, struct ifnet *, int); | static int vxlan_set_reqcap(struct vxlan_softc *, struct ifnet *, int); | ||||
| static void vxlan_set_hwcaps(struct vxlan_softc *); | static void vxlan_set_hwcaps(struct vxlan_softc *); | ||||
| static int vxlan_clone_create(struct if_clone *, char *, size_t, | static int vxlan_clone_create(struct if_clone *, char *, size_t, | ||||
| struct ifc_data *, struct ifnet **); | struct ifc_data *, struct ifnet **); | ||||
| ▲ Show 20 Lines • Show All 2,539 Lines • ▼ Show 20 Lines | vxlan_input(struct vxlan_socket *vso, uint32_t vni, struct mbuf **m0, | ||||
| *m0 = NULL; | *m0 = NULL; | ||||
| error = 0; | error = 0; | ||||
| out: | out: | ||||
| vxlan_release(sc); | vxlan_release(sc); | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| static int | static void | ||||
| vxlan_stats_alloc(struct vxlan_softc *sc) | vxlan_stats_alloc(struct vxlan_softc *sc) | ||||
| { | { | ||||
| struct vxlan_statistics *stats = &sc->vxl_stats; | struct vxlan_statistics *stats = &sc->vxl_stats; | ||||
| stats->txcsum = counter_u64_alloc(M_WAITOK); | stats->txcsum = counter_u64_alloc(M_WAITOK); | ||||
| if (stats->txcsum == NULL) | |||||
| goto failed; | |||||
| stats->tso = counter_u64_alloc(M_WAITOK); | stats->tso = counter_u64_alloc(M_WAITOK); | ||||
| if (stats->tso == NULL) | |||||
| goto failed; | |||||
| stats->rxcsum = counter_u64_alloc(M_WAITOK); | stats->rxcsum = counter_u64_alloc(M_WAITOK); | ||||
| if (stats->rxcsum == NULL) | |||||
| goto failed; | |||||
| return (0); | |||||
| failed: | |||||
| vxlan_stats_free(sc); | |||||
| return (ENOMEM); | |||||
| } | } | ||||
| static void | static void | ||||
| vxlan_stats_free(struct vxlan_softc *sc) | vxlan_stats_free(struct vxlan_softc *sc) | ||||
| { | { | ||||
| struct vxlan_statistics *stats = &sc->vxl_stats; | struct vxlan_statistics *stats = &sc->vxl_stats; | ||||
| if (stats->txcsum != NULL) { | |||||
| counter_u64_free(stats->txcsum); | counter_u64_free(stats->txcsum); | ||||
kp: counter_u64_free(NULL) is safe (now), so even without the other changes getting rid of the… | |||||
zleiAuthorUnsubmitted Done Inline ActionsIndeed. zlei: Indeed. | |||||
| stats->txcsum = NULL; | |||||
| } | |||||
| if (stats->tso != NULL) { | |||||
| counter_u64_free(stats->tso); | counter_u64_free(stats->tso); | ||||
| stats->tso = NULL; | |||||
| } | |||||
| if (stats->rxcsum != NULL) { | |||||
| counter_u64_free(stats->rxcsum); | counter_u64_free(stats->rxcsum); | ||||
| stats->rxcsum = NULL; | |||||
| } | } | ||||
| } | |||||
| static void | static void | ||||
| vxlan_set_default_config(struct vxlan_softc *sc) | vxlan_set_default_config(struct vxlan_softc *sc) | ||||
| { | { | ||||
| sc->vxl_flags |= VXLAN_FLAG_LEARN; | sc->vxl_flags |= VXLAN_FLAG_LEARN; | ||||
| sc->vxl_vni = VXLAN_VNI_MAX; | sc->vxl_vni = VXLAN_VNI_MAX; | ||||
| ▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | vxlan_clone_create(struct if_clone *ifc, char *name, size_t len, | ||||
| struct ifnet *ifp; | struct ifnet *ifp; | ||||
| struct ifvxlanparam vxlp; | struct ifvxlanparam vxlp; | ||||
| int error; | int error; | ||||
| sc = malloc(sizeof(struct vxlan_softc), M_VXLAN, M_WAITOK | M_ZERO); | sc = malloc(sizeof(struct vxlan_softc), M_VXLAN, M_WAITOK | M_ZERO); | ||||
| sc->vxl_unit = ifd->unit; | sc->vxl_unit = ifd->unit; | ||||
| sc->vxl_fibnum = curthread->td_proc->p_fibnum; | sc->vxl_fibnum = curthread->td_proc->p_fibnum; | ||||
| vxlan_set_default_config(sc); | vxlan_set_default_config(sc); | ||||
| error = vxlan_stats_alloc(sc); | |||||
| if (error != 0) | |||||
| goto fail; | |||||
| if (ifd->params != NULL) { | if (ifd->params != NULL) { | ||||
| error = ifc_copyin(ifd, &vxlp, sizeof(vxlp)); | error = ifc_copyin(ifd, &vxlp, sizeof(vxlp)); | ||||
| if (error) | if (error) | ||||
| goto fail; | goto fail; | ||||
| error = vxlan_set_user_config(sc, &vxlp); | error = vxlan_set_user_config(sc, &vxlp); | ||||
| if (error) | if (error) | ||||
| goto fail; | goto fail; | ||||
| } | } | ||||
| vxlan_stats_alloc(sc); | |||||
| ifp = if_alloc(IFT_ETHER); | ifp = if_alloc(IFT_ETHER); | ||||
| sc->vxl_ifp = ifp; | sc->vxl_ifp = ifp; | ||||
| rm_init(&sc->vxl_lock, "vxlanrm"); | rm_init(&sc->vxl_lock, "vxlanrm"); | ||||
| callout_init_rw(&sc->vxl_callout, &sc->vxl_lock, 0); | callout_init_rw(&sc->vxl_callout, &sc->vxl_lock, 0); | ||||
| sc->vxl_port_hash_key = arc4random(); | sc->vxl_port_hash_key = arc4random(); | ||||
| vxlan_ftable_init(sc); | vxlan_ftable_init(sc); | ||||
| vxlan_sysctl_setup(sc); | vxlan_sysctl_setup(sc); | ||||
| ▲ Show 20 Lines • Show All 460 Lines • Show Last 20 Lines | |||||
counter_u64_free(NULL) is safe (now), so even without the other changes getting rid of the check would be fine.