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

Function vlan_clone_create

freebsd/net/if_vlan.c:976–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

974}
975
976static int
977vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
978{
979 char *dp;
980 bool wildcard = false;
981 bool subinterface = false;
982 int unit;
983 int error;
984 int vid = 0;
985 uint16_t proto = ETHERTYPE_VLAN;
986 struct ifvlan *ifv;
987 struct ifnet *ifp;
988 struct ifnet *p = NULL;
989 struct ifaddr *ifa;
990 struct sockaddr_dl *sdl;
991 struct vlanreq vlr;
992 static const u_char eaddr[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */
993
994
995 /*
996 * There are three ways to specify the cloned device:
997 * o pass a parameter block with the clone request.
998 * o specify parameters in the text of the clone device name
999 * o specify no parameters and get an unattached device that
1000 * must be configured separately.
1001 * The first technique is preferred; the latter two are supported
1002 * for backwards compatibility.
1003 *
1004 * XXXRW: Note historic use of the word "tag" here. New ioctls may be
1005 * called for.
1006 */
1007
1008 if (params) {
1009 error = copyin(params, &vlr, sizeof(vlr));
1010 if (error)
1011 return error;
1012 vid = vlr.vlr_tag;
1013 proto = vlr.vlr_proto;
1014
1015 p = ifunit_ref(vlr.vlr_parent);
1016 if (p == NULL)
1017 return (ENXIO);
1018 }
1019
1020 if ((error = ifc_name2unit(name, &unit)) == 0) {
1021
1022 /*
1023 * vlanX interface. Set wildcard to true if the unit number
1024 * is not fixed (-1)
1025 */
1026 wildcard = (unit < 0);
1027 } else {
1028 struct ifnet *p_tmp = vlan_clone_match_ethervid(name, &vid);
1029 if (p_tmp != NULL) {
1030 error = 0;
1031 subinterface = true;
1032 unit = IF_DUNIT_NONE;
1033 wildcard = false;

Callers

nothing calls this directly

Calls 15

ifunit_refFunction · 0.85
ifc_name2unitFunction · 0.85
if_releFunction · 0.85
ifc_alloc_unitFunction · 0.85
snprintfFunction · 0.85
mallocFunction · 0.85
if_allocFunction · 0.85
ifc_free_unitFunction · 0.85
ether_ifattachFunction · 0.85
vlan_configFunction · 0.85
ether_ifdetachFunction · 0.85

Tested by

no test coverage detected