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

Function iflib_if_ioctl

freebsd/net/iflib.c:4234–4411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4232 IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM | IFCAP_NOMAP)
4233
4234static int
4235iflib_if_ioctl(if_t ifp, u_long command, caddr_t data)
4236{
4237 if_ctx_t ctx = if_getsoftc(ifp);
4238 struct ifreq *ifr = (struct ifreq *)data;
4239#if defined(INET) || defined(INET6)
4240 struct ifaddr *ifa = (struct ifaddr *)data;
4241#endif
4242 bool avoid_reset = false;
4243 int err = 0, reinit = 0, bits;
4244
4245 switch (command) {
4246 case SIOCSIFADDR:
4247#ifdef INET
4248 if (ifa->ifa_addr->sa_family == AF_INET)
4249 avoid_reset = true;
4250#endif
4251#ifdef INET6
4252 if (ifa->ifa_addr->sa_family == AF_INET6)
4253 avoid_reset = true;
4254#endif
4255 /*
4256 ** Calling init results in link renegotiation,
4257 ** so we avoid doing it when possible.
4258 */
4259 if (avoid_reset) {
4260 if_setflagbits(ifp, IFF_UP,0);
4261 if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING))
4262 reinit = 1;
4263#ifdef INET
4264 if (!(if_getflags(ifp) & IFF_NOARP))
4265 arp_ifinit(ifp, ifa);
4266#endif
4267 } else
4268 err = ether_ioctl(ifp, command, data);
4269 break;
4270 case SIOCSIFMTU:
4271 CTX_LOCK(ctx);
4272 if (ifr->ifr_mtu == if_getmtu(ifp)) {
4273 CTX_UNLOCK(ctx);
4274 break;
4275 }
4276 bits = if_getdrvflags(ifp);
4277 /* stop the driver and free any clusters before proceeding */
4278 iflib_stop(ctx);
4279
4280 if ((err = IFDI_MTU_SET(ctx, ifr->ifr_mtu)) == 0) {
4281 STATE_LOCK(ctx);
4282 if (ifr->ifr_mtu > ctx->ifc_max_fl_buf_size)
4283 ctx->ifc_flags |= IFC_MULTISEG;
4284 else
4285 ctx->ifc_flags &= ~IFC_MULTISEG;
4286 STATE_UNLOCK(ctx);
4287 err = if_setmtu(ifp, ifr->ifr_mtu);
4288 }
4289 iflib_init_locked(ctx);
4290 STATE_LOCK(ctx);
4291 if_setdrvflags(ifp, bits);

Callers

nothing calls this directly

Calls 15

if_getsoftcFunction · 0.85
if_setflagbitsFunction · 0.85
if_getdrvflagsFunction · 0.85
if_getflagsFunction · 0.85
arp_ifinitFunction · 0.85
ether_ioctlFunction · 0.85
if_getmtuFunction · 0.85
iflib_stopFunction · 0.85
if_setmtuFunction · 0.85
iflib_init_lockedFunction · 0.85
if_setdrvflagsFunction · 0.85
ifmedia_ioctlFunction · 0.85

Tested by

no test coverage detected