MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vxlan_ftable_entry_insert

Function vxlan_ftable_entry_insert

freebsd/net/if_vxlan.c:782–817  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780}
781
782static int
783vxlan_ftable_entry_insert(struct vxlan_softc *sc,
784 struct vxlan_ftable_entry *fe)
785{
786 struct vxlan_ftable_entry *lfe;
787 uint32_t hash;
788 int dir;
789
790 VXLAN_LOCK_WASSERT(sc);
791 hash = VXLAN_SC_FTABLE_HASH(sc, fe->vxlfe_mac);
792
793 lfe = LIST_FIRST(&sc->vxl_ftable[hash]);
794 if (lfe == NULL) {
795 LIST_INSERT_HEAD(&sc->vxl_ftable[hash], fe, vxlfe_hash);
796 goto out;
797 }
798
799 do {
800 dir = vxlan_ftable_addr_cmp(fe->vxlfe_mac, lfe->vxlfe_mac);
801 if (dir == 0)
802 return (EEXIST);
803 if (dir > 0) {
804 LIST_INSERT_BEFORE(lfe, fe, vxlfe_hash);
805 goto out;
806 } else if (LIST_NEXT(lfe, vxlfe_hash) == NULL) {
807 LIST_INSERT_AFTER(lfe, fe, vxlfe_hash);
808 goto out;
809 } else
810 lfe = LIST_NEXT(lfe, vxlfe_hash);
811 } while (lfe != NULL);
812
813out:
814 sc->vxl_ftable_cnt++;
815
816 return (0);
817}
818
819static struct vxlan_ftable_entry *
820vxlan_ftable_entry_lookup(struct vxlan_softc *sc, const uint8_t *mac)

Callers 2

Calls 1

vxlan_ftable_addr_cmpFunction · 0.85

Tested by

no test coverage detected