| 987 | } |
| 988 | |
| 989 | static void |
| 990 | tunrename(void *arg __unused, struct ifnet *ifp) |
| 991 | { |
| 992 | struct tuntap_softc *tp; |
| 993 | int error; |
| 994 | |
| 995 | if ((ifp->if_flags & IFF_RENAMING) == 0) |
| 996 | return; |
| 997 | |
| 998 | if (tuntap_driver_from_ifnet(ifp) == NULL) |
| 999 | return; |
| 1000 | |
| 1001 | /* |
| 1002 | * We need to grab the ioctl sx long enough to make sure the softc is |
| 1003 | * still there. If it is, we can safely try to busy the tun device. |
| 1004 | * The busy may fail if the device is currently dying, in which case |
| 1005 | * we do nothing. If it doesn't fail, the busy count stops the device |
| 1006 | * from dying until we've created the alias (that will then be |
| 1007 | * subsequently destroyed). |
| 1008 | */ |
| 1009 | sx_xlock(&tun_ioctl_sx); |
| 1010 | tp = ifp->if_softc; |
| 1011 | if (tp == NULL) { |
| 1012 | sx_xunlock(&tun_ioctl_sx); |
| 1013 | return; |
| 1014 | } |
| 1015 | error = tun_busy(tp); |
| 1016 | sx_xunlock(&tun_ioctl_sx); |
| 1017 | if (error != 0) |
| 1018 | return; |
| 1019 | if (tp->tun_alias != NULL) { |
| 1020 | destroy_dev(tp->tun_alias); |
| 1021 | tp->tun_alias = NULL; |
| 1022 | } |
| 1023 | |
| 1024 | if (strcmp(ifp->if_xname, tp->tun_dev->si_name) == 0) |
| 1025 | goto out; |
| 1026 | |
| 1027 | /* |
| 1028 | * Failure's ok, aliases are created on a best effort basis. If a |
| 1029 | * tun user/consumer decides to rename the interface to conflict with |
| 1030 | * another device (non-ifnet) on the system, we will assume they know |
| 1031 | * what they are doing. make_dev_alias_p won't touch tun_alias on |
| 1032 | * failure, so we use it but ignore the return value. |
| 1033 | */ |
| 1034 | make_dev_alias_p(MAKEDEV_CHECKNAME, &tp->tun_alias, tp->tun_dev, "%s", |
| 1035 | ifp->if_xname); |
| 1036 | out: |
| 1037 | tun_unbusy(tp); |
| 1038 | } |
| 1039 | |
| 1040 | static int |
| 1041 | tunopen(struct cdev *dev, int flag, int mode, struct thread *td) |
nothing calls this directly
no test coverage detected