Use soclose() instead of sofree() when initializing the configuration stack IP.

This commit is contained in:
fengbojiang 2024-09-27 16:25:18 +08:00
parent a31cb17ac8
commit 68e1f5aa90
2 changed files with 10 additions and 10 deletions

View File

@ -79,7 +79,7 @@ int lo_set_defaultaddr(void)
char *netmask="255.0.0.0";
struct ifnet *ifp=NULL;
int ret;
IFNET_WLOCK();
TAILQ_FOREACH(ifp, &V_ifnet, if_link)
if ( (ifp->if_flags & IFF_LOOPBACK) != 0 )
@ -88,16 +88,16 @@ int lo_set_defaultaddr(void)
if(ifp == NULL)
return -1;
bzero(&req, sizeof req);
strcpy(req.ifra_name, ifp->if_xname);
struct sockaddr_in sa;
bzero(&sa, sizeof(sa));
sa.sin_len = sizeof(sa);
sa.sin_family = AF_INET;
inet_pton(AF_INET, addr, &sa.sin_addr.s_addr);
bcopy(&sa, &req.ifra_addr, sizeof(sa));
@ -113,7 +113,7 @@ int lo_set_defaultaddr(void)
return ret;
ret = ifioctl(so, SIOCAIFADDR, (caddr_t)&req, curthread);
sofree(so);
soclose(so);
return ret;
}

View File

@ -465,7 +465,7 @@ ff_veth_setaddr(struct ff_veth_softc *sc, const char *if_name)
socreate(AF_INET, &so, SOCK_DGRAM, 0, curthread->td_ucred, curthread);
int ret = ifioctl(so, SIOCAIFADDR, (caddr_t)&req, curthread);
sofree(so);
soclose(so);
return ret;
}
@ -538,7 +538,7 @@ ff_veth_setvaddr(struct ff_veth_softc *sc, struct ff_port_cfg *cfg, const char *
}
done:
sofree(so);
soclose(so);
return ret;
}
@ -731,7 +731,7 @@ ff_veth_setaddr6(struct ff_veth_softc *sc, const char *if_name)
socreate(AF_INET6, &so, SOCK_DGRAM, 0, curthread->td_ucred, curthread);
int ret = ifioctl(so, SIOCAIFADDR_IN6, (caddr_t)&ifr6, curthread);
sofree(so);
soclose(so);
return ret;
}
@ -800,7 +800,7 @@ ff_veth_setvaddr6(struct ff_veth_softc *sc, struct ff_port_cfg *cfg, const char
}
done:
sofree(so);
soclose(so);
return ret;
}