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

Function lagg_port_create

freebsd/net/if_lagg.c:720–888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718}
719
720static int
721lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp)
722{
723 struct lagg_softc *sc_ptr;
724 struct lagg_port *lp, *tlp;
725 struct ifreq ifr;
726 int error, i, oldmtu;
727 int if_type;
728 uint64_t *pval;
729
730 LAGG_XLOCK_ASSERT(sc);
731
732 if (sc->sc_ifp == ifp) {
733 if_printf(sc->sc_ifp,
734 "cannot add a lagg to itself as a port\n");
735 return (EINVAL);
736 }
737
738 if (sc->sc_destroying == 1)
739 return (ENXIO);
740
741 /* Limit the maximal number of lagg ports */
742 if (sc->sc_count >= LAGG_MAX_PORTS)
743 return (ENOSPC);
744
745 /* Check if port has already been associated to a lagg */
746 if (ifp->if_lagg != NULL) {
747 /* Port is already in the current lagg? */
748 lp = (struct lagg_port *)ifp->if_lagg;
749 if (lp->lp_softc == sc)
750 return (EEXIST);
751 return (EBUSY);
752 }
753
754 switch (sc->sc_ifp->if_type) {
755 case IFT_ETHER:
756 /* XXX Disallow non-ethernet interfaces (this should be any of 802) */
757 if (ifp->if_type != IFT_ETHER && ifp->if_type != IFT_L2VLAN)
758 return (EPROTONOSUPPORT);
759 if_type = IFT_IEEE8023ADLAG;
760 break;
761 case IFT_INFINIBAND:
762 /* XXX Disallow non-infiniband interfaces */
763 if (ifp->if_type != IFT_INFINIBAND)
764 return (EPROTONOSUPPORT);
765 if_type = IFT_INFINIBANDLAG;
766 break;
767 default:
768 break;
769 }
770
771 /* Allow the first Ethernet member to define the MTU */
772 oldmtu = -1;
773 if (CK_SLIST_EMPTY(&sc->sc_ports)) {
774 sc->sc_ifp->if_mtu = ifp->if_mtu;
775 } else if (sc->sc_ifp->if_mtu != ifp->if_mtu) {
776 if (ifp->if_ioctl == NULL) {
777 if_printf(sc->sc_ifp, "cannot change MTU for %s\n",

Callers 1

lagg_ioctlFunction · 0.85

Calls 14

if_printfFunction · 0.85
mallocFunction · 0.85
lagg_port_checkstackingFunction · 0.85
if_refFunction · 0.85
lagg_proto_lladdrFunction · 0.85
if_setlladdrFunction · 0.85
lagg_setflagsFunction · 0.85
lagg_setmultiFunction · 0.85
lagg_proto_addportFunction · 0.85
lagg_port_destroyFunction · 0.85
lagg_capabilitiesFunction · 0.85
lagg_linkstateFunction · 0.85

Tested by

no test coverage detected