if.c (126080) | if.c (126264) |
---|---|
1/* 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)if.c 8.5 (Berkeley) 1/9/95 | 1/* 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)if.c 8.5 (Berkeley) 1/9/95 |
34 * $FreeBSD: head/sys/net/if.c 126080 2004-02-21 21:10:55Z phk $ | 34 * $FreeBSD: head/sys/net/if.c 126264 2004-02-26 04:27:55Z mlaier $ |
35 */ 36 37#include "opt_compat.h" 38#include "opt_inet6.h" 39#include "opt_inet.h" 40#include "opt_mac.h" 41 42#include <sys/param.h> --- 399 unchanged lines hidden (view full) --- 442 sdl->sdl_data[--namelen] = 0xff; 443 ifa->ifa_refcnt = 1; 444 TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link); 445 ifp->if_broadcastaddr = 0; /* reliably crash if used uninitialized */ 446 447 if (domains) 448 if_attachdomain1(ifp); 449 | 35 */ 36 37#include "opt_compat.h" 38#include "opt_inet6.h" 39#include "opt_inet.h" 40#include "opt_mac.h" 41 42#include <sys/param.h> --- 399 unchanged lines hidden (view full) --- 442 sdl->sdl_data[--namelen] = 0xff; 443 ifa->ifa_refcnt = 1; 444 TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link); 445 ifp->if_broadcastaddr = 0; /* reliably crash if used uninitialized */ 446 447 if (domains) 448 if_attachdomain1(ifp); 449 |
450 EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); 451 |
|
450 /* Announce the interface. */ 451 rt_ifannouncemsg(ifp, IFAN_ARRIVAL); 452} 453 454static void 455if_attachdomain(void *dummy) 456{ 457 struct ifnet *ifp; --- 50 unchanged lines hidden (view full) --- 508if_detach(struct ifnet *ifp) 509{ 510 struct ifaddr *ifa, *next; 511 struct radix_node_head *rnh; 512 int s; 513 int i; 514 struct domain *dp; 515 | 452 /* Announce the interface. */ 453 rt_ifannouncemsg(ifp, IFAN_ARRIVAL); 454} 455 456static void 457if_attachdomain(void *dummy) 458{ 459 struct ifnet *ifp; --- 50 unchanged lines hidden (view full) --- 510if_detach(struct ifnet *ifp) 511{ 512 struct ifaddr *ifa, *next; 513 struct radix_node_head *rnh; 514 int s; 515 int i; 516 struct domain *dp; 517 |
518 EVENTHANDLER_INVOKE(ifnet_departure_event, ifp); |
|
516 /* 517 * Remove routes and flush queues. 518 */ 519 s = splnet(); 520 if_down(ifp); 521 522 /* 523 * Remove address from ifindex_table[] and maybe decrement if_index. --- 314 unchanged lines hidden (view full) --- 838 ("%s: failed to create required interface %s%d", 839 __func__, ifc->ifc_name, unit)); 840 841 /* Allocate the unit in the bitmap. */ 842 bytoff = unit >> 3; 843 bitoff = unit - (bytoff << 3); 844 ifc->ifc_units[bytoff] |= (1 << bitoff); 845 } | 519 /* 520 * Remove routes and flush queues. 521 */ 522 s = splnet(); 523 if_down(ifp); 524 525 /* 526 * Remove address from ifindex_table[] and maybe decrement if_index. --- 314 unchanged lines hidden (view full) --- 841 ("%s: failed to create required interface %s%d", 842 __func__, ifc->ifc_name, unit)); 843 844 /* Allocate the unit in the bitmap. */ 845 bytoff = unit >> 3; 846 bitoff = unit - (bytoff << 3); 847 ifc->ifc_units[bytoff] |= (1 << bitoff); 848 } |
849 EVENTHANDLER_INVOKE(if_clone_event, ifc); |
|
846} 847 848/* 849 * Unregister a network interface cloner. 850 */ 851void 852if_clone_detach(struct if_clone *ifc) 853{ --- 519 unchanged lines hidden (view full) --- 1373 if (error) 1374 return (error); 1375 error = copyinstr(ifr->ifr_data, new_name, IFNAMSIZ, NULL); 1376 if (error) 1377 return (error); 1378 if (ifunit(new_name) != NULL) 1379 return (EEXIST); 1380 | 850} 851 852/* 853 * Unregister a network interface cloner. 854 */ 855void 856if_clone_detach(struct if_clone *ifc) 857{ --- 519 unchanged lines hidden (view full) --- 1377 if (error) 1378 return (error); 1379 error = copyinstr(ifr->ifr_data, new_name, IFNAMSIZ, NULL); 1380 if (error) 1381 return (error); 1382 if (ifunit(new_name) != NULL) 1383 return (EEXIST); 1384 |
1385 EVENTHANDLER_INVOKE(ifnet_departure_event, ifp); |
|
1381 /* Announce the departure of the interface. */ 1382 rt_ifannouncemsg(ifp, IFAN_DEPARTURE); 1383 1384 strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname)); 1385 ifa = TAILQ_FIRST(&ifp->if_addrhead); 1386 IFA_LOCK(ifa); 1387 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 1388 namelen = strlen(new_name); --- 10 unchanged lines hidden (view full) --- 1399 bcopy(new_name, sdl->sdl_data, namelen); 1400 sdl->sdl_nlen = namelen; 1401 sdl = (struct sockaddr_dl *)ifa->ifa_netmask; 1402 bzero(sdl->sdl_data, onamelen); 1403 while (namelen != 0) 1404 sdl->sdl_data[--namelen] = 0xff; 1405 IFA_UNLOCK(ifa); 1406 | 1386 /* Announce the departure of the interface. */ 1387 rt_ifannouncemsg(ifp, IFAN_DEPARTURE); 1388 1389 strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname)); 1390 ifa = TAILQ_FIRST(&ifp->if_addrhead); 1391 IFA_LOCK(ifa); 1392 sdl = (struct sockaddr_dl *)ifa->ifa_addr; 1393 namelen = strlen(new_name); --- 10 unchanged lines hidden (view full) --- 1404 bcopy(new_name, sdl->sdl_data, namelen); 1405 sdl->sdl_nlen = namelen; 1406 sdl = (struct sockaddr_dl *)ifa->ifa_netmask; 1407 bzero(sdl->sdl_data, onamelen); 1408 while (namelen != 0) 1409 sdl->sdl_data[--namelen] = 0xff; 1410 IFA_UNLOCK(ifa); 1411 |
1412 EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); |
|
1407 /* Announce the return of the interface. */ 1408 rt_ifannouncemsg(ifp, IFAN_ARRIVAL); 1409 break; 1410 1411 case SIOCSIFMETRIC: 1412 error = suser(td); 1413 if (error) 1414 return (error); --- 668 unchanged lines hidden --- | 1413 /* Announce the return of the interface. */ 1414 rt_ifannouncemsg(ifp, IFAN_ARRIVAL); 1415 break; 1416 1417 case SIOCSIFMETRIC: 1418 error = suser(td); 1419 if (error) 1420 return (error); --- 668 unchanged lines hidden --- |