in.c (194760) | in.c (194951) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (C) 2001 WIDE Project. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 17 unchanged lines hidden (view full) --- 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)in.c 8.4 (Berkeley) 1/9/95 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * Copyright (C) 2001 WIDE Project. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 17 unchanged lines hidden (view full) --- 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * @(#)in.c 8.4 (Berkeley) 1/9/95 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/netinet/in.c 194760 2009-06-23 20:19:09Z rwatson $"); | 34__FBSDID("$FreeBSD: head/sys/netinet/in.c 194951 2009-06-25 11:52:33Z rwatson $"); |
35 36#include "opt_carp.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sockio.h> 41#include <sys/malloc.h> 42#include <sys/priv.h> --- 52 unchanged lines hidden (view full) --- 95 */ 96int 97in_localaddr(struct in_addr in) 98{ 99 INIT_VNET_INET(curvnet); 100 register u_long i = ntohl(in.s_addr); 101 register struct in_ifaddr *ia; 102 | 35 36#include "opt_carp.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sockio.h> 41#include <sys/malloc.h> 42#include <sys/priv.h> --- 52 unchanged lines hidden (view full) --- 95 */ 96int 97in_localaddr(struct in_addr in) 98{ 99 INIT_VNET_INET(curvnet); 100 register u_long i = ntohl(in.s_addr); 101 register struct in_ifaddr *ia; 102 |
103 IN_IFADDR_RLOCK(); |
|
103 if (V_subnetsarelocal) { | 104 if (V_subnetsarelocal) { |
104 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) 105 if ((i & ia->ia_netmask) == ia->ia_net) | 105 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { 106 if ((i & ia->ia_netmask) == ia->ia_net) { 107 IN_IFADDR_RUNLOCK(); |
106 return (1); | 108 return (1); |
109 } 110 } |
|
107 } else { | 111 } else { |
108 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) 109 if ((i & ia->ia_subnetmask) == ia->ia_subnet) | 112 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { 113 if ((i & ia->ia_subnetmask) == ia->ia_subnet) { 114 IN_IFADDR_RUNLOCK(); |
110 return (1); | 115 return (1); |
116 } 117 } |
|
111 } | 118 } |
119 IN_IFADDR_RUNLOCK(); |
|
112 return (0); 113} 114 115/* 116 * Return 1 if an internet address is for the local host and configured 117 * on one of its interfaces. 118 */ 119int 120in_localip(struct in_addr in) 121{ 122 INIT_VNET_INET(curvnet); 123 struct in_ifaddr *ia; 124 | 120 return (0); 121} 122 123/* 124 * Return 1 if an internet address is for the local host and configured 125 * on one of its interfaces. 126 */ 127int 128in_localip(struct in_addr in) 129{ 130 INIT_VNET_INET(curvnet); 131 struct in_ifaddr *ia; 132 |
133 IN_IFADDR_RLOCK(); |
|
125 LIST_FOREACH(ia, INADDR_HASH(in.s_addr), ia_hash) { | 134 LIST_FOREACH(ia, INADDR_HASH(in.s_addr), ia_hash) { |
126 if (IA_SIN(ia)->sin_addr.s_addr == in.s_addr) | 135 if (IA_SIN(ia)->sin_addr.s_addr == in.s_addr) { 136 IN_IFADDR_RUNLOCK(); |
127 return (1); | 137 return (1); |
138 } |
|
128 } | 139 } |
140 IN_IFADDR_RUNLOCK(); |
|
129 return (0); 130} 131 132/* 133 * Determine whether an IP address is in a reserved set of addresses 134 * that may not be forwarded, or whether datagrams to that destination 135 * may be forwarded. 136 */ --- 80 unchanged lines hidden (view full) --- 217 register struct ifreq *ifr = (struct ifreq *)data; 218 register struct in_ifaddr *ia, *iap; 219 register struct ifaddr *ifa; 220 struct in_addr allhosts_addr; 221 struct in_addr dst; 222 struct in_ifinfo *ii; 223 struct in_aliasreq *ifra = (struct in_aliasreq *)data; 224 struct sockaddr_in oldaddr; | 141 return (0); 142} 143 144/* 145 * Determine whether an IP address is in a reserved set of addresses 146 * that may not be forwarded, or whether datagrams to that destination 147 * may be forwarded. 148 */ --- 80 unchanged lines hidden (view full) --- 229 register struct ifreq *ifr = (struct ifreq *)data; 230 register struct in_ifaddr *ia, *iap; 231 register struct ifaddr *ifa; 232 struct in_addr allhosts_addr; 233 struct in_addr dst; 234 struct in_ifinfo *ii; 235 struct in_aliasreq *ifra = (struct in_aliasreq *)data; 236 struct sockaddr_in oldaddr; |
225 int error, hostIsNew, iaIsNew, maskIsNew, s; | 237 int error, hostIsNew, iaIsNew, maskIsNew; |
226 int iaIsFirst; 227 228 ia = NULL; 229 iaIsFirst = 0; 230 iaIsNew = 0; 231 allhosts_addr.s_addr = htonl(INADDR_ALLHOSTS_GROUP); 232 233 /* --- 74 unchanged lines hidden (view full) --- 308 309 /* 310 * Find address for this interface, if it exists. 311 * 312 * If an alias address was specified, find that one instead of the 313 * first one on the interface, if possible. 314 */ 315 dst = ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr; | 238 int iaIsFirst; 239 240 ia = NULL; 241 iaIsFirst = 0; 242 iaIsNew = 0; 243 allhosts_addr.s_addr = htonl(INADDR_ALLHOSTS_GROUP); 244 245 /* --- 74 unchanged lines hidden (view full) --- 320 321 /* 322 * Find address for this interface, if it exists. 323 * 324 * If an alias address was specified, find that one instead of the 325 * first one on the interface, if possible. 326 */ 327 dst = ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr; |
328 IN_IFADDR_RLOCK(); |
|
316 LIST_FOREACH(iap, INADDR_HASH(dst.s_addr), ia_hash) { 317 if (iap->ia_ifp == ifp && 318 iap->ia_addr.sin_addr.s_addr == dst.s_addr) { 319 if (td == NULL || prison_check_ip4(td->td_ucred, 320 &dst) == 0) 321 ia = iap; 322 break; 323 } 324 } 325 if (ia != NULL) 326 ifa_ref(&ia->ia_ifa); | 329 LIST_FOREACH(iap, INADDR_HASH(dst.s_addr), ia_hash) { 330 if (iap->ia_ifp == ifp && 331 iap->ia_addr.sin_addr.s_addr == dst.s_addr) { 332 if (td == NULL || prison_check_ip4(td->td_ucred, 333 &dst) == 0) 334 ia = iap; 335 break; 336 } 337 } 338 if (ia != NULL) 339 ifa_ref(&ia->ia_ifa); |
340 IN_IFADDR_RUNLOCK(); |
|
327 if (ia == NULL) { 328 IF_ADDR_LOCK(ifp); 329 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 330 iap = ifatoia(ifa); 331 if (iap->ia_addr.sin_family == AF_INET) { 332 if (td != NULL && 333 prison_check_ip4(td->td_ucred, 334 &iap->ia_addr.sin_addr) != 0) --- 11 unchanged lines hidden (view full) --- 346 347 error = 0; 348 switch (cmd) { 349 case SIOCAIFADDR: 350 case SIOCDIFADDR: 351 if (ifra->ifra_addr.sin_family == AF_INET) { 352 struct in_ifaddr *oia; 353 | 341 if (ia == NULL) { 342 IF_ADDR_LOCK(ifp); 343 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { 344 iap = ifatoia(ifa); 345 if (iap->ia_addr.sin_family == AF_INET) { 346 if (td != NULL && 347 prison_check_ip4(td->td_ucred, 348 &iap->ia_addr.sin_addr) != 0) --- 11 unchanged lines hidden (view full) --- 360 361 error = 0; 362 switch (cmd) { 363 case SIOCAIFADDR: 364 case SIOCDIFADDR: 365 if (ifra->ifra_addr.sin_family == AF_INET) { 366 struct in_ifaddr *oia; 367 |
368 IN_IFADDR_RLOCK(); |
|
354 for (oia = ia; ia; ia = TAILQ_NEXT(ia, ia_link)) { 355 if (ia->ia_ifp == ifp && 356 ia->ia_addr.sin_addr.s_addr == 357 ifra->ifra_addr.sin_addr.s_addr) 358 break; 359 } 360 if (ia != NULL && ia != oia) 361 ifa_ref(&ia->ia_ifa); 362 if (oia != NULL && ia != oia) 363 ifa_free(&oia->ia_ifa); | 369 for (oia = ia; ia; ia = TAILQ_NEXT(ia, ia_link)) { 370 if (ia->ia_ifp == ifp && 371 ia->ia_addr.sin_addr.s_addr == 372 ifra->ifra_addr.sin_addr.s_addr) 373 break; 374 } 375 if (ia != NULL && ia != oia) 376 ifa_ref(&ia->ia_ifa); 377 if (oia != NULL && ia != oia) 378 ifa_free(&oia->ia_ifa); |
379 IN_IFADDR_RUNLOCK(); |
|
364 if ((ifp->if_flags & IFF_POINTOPOINT) 365 && (cmd == SIOCAIFADDR) 366 && (ifra->ifra_dstaddr.sin_addr.s_addr 367 == INADDR_ANY)) { 368 error = EDESTADDRREQ; 369 goto out; 370 } 371 } --- 28 unchanged lines hidden (view full) --- 400 } 401 ia->ia_ifp = ifp; 402 403 ifa_ref(ifa); /* if_addrhead */ 404 IF_ADDR_LOCK(ifp); 405 TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); 406 IF_ADDR_UNLOCK(ifp); 407 ifa_ref(ifa); /* in_ifaddrhead */ | 380 if ((ifp->if_flags & IFF_POINTOPOINT) 381 && (cmd == SIOCAIFADDR) 382 && (ifra->ifra_dstaddr.sin_addr.s_addr 383 == INADDR_ANY)) { 384 error = EDESTADDRREQ; 385 goto out; 386 } 387 } --- 28 unchanged lines hidden (view full) --- 416 } 417 ia->ia_ifp = ifp; 418 419 ifa_ref(ifa); /* if_addrhead */ 420 IF_ADDR_LOCK(ifp); 421 TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); 422 IF_ADDR_UNLOCK(ifp); 423 ifa_ref(ifa); /* in_ifaddrhead */ |
408 s = splnet(); | 424 IN_IFADDR_WLOCK(); |
409 TAILQ_INSERT_TAIL(&V_in_ifaddrhead, ia, ia_link); | 425 TAILQ_INSERT_TAIL(&V_in_ifaddrhead, ia, ia_link); |
410 splx(s); | 426 IN_IFADDR_WUNLOCK(); |
411 iaIsNew = 1; 412 } 413 break; 414 415 case SIOCSIFBRDADDR: 416 case SIOCGIFADDR: 417 case SIOCGIFNETMASK: 418 case SIOCGIFDSTADDR: --- 154 unchanged lines hidden (view full) --- 573 default: 574 panic("in_control: unsupported ioctl"); 575 } 576 577 IF_ADDR_LOCK(ifp); 578 TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); 579 IF_ADDR_UNLOCK(ifp); 580 ifa_free(&ia->ia_ifa); /* if_addrhead */ | 427 iaIsNew = 1; 428 } 429 break; 430 431 case SIOCSIFBRDADDR: 432 case SIOCGIFADDR: 433 case SIOCGIFNETMASK: 434 case SIOCGIFDSTADDR: --- 154 unchanged lines hidden (view full) --- 589 default: 590 panic("in_control: unsupported ioctl"); 591 } 592 593 IF_ADDR_LOCK(ifp); 594 TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); 595 IF_ADDR_UNLOCK(ifp); 596 ifa_free(&ia->ia_ifa); /* if_addrhead */ |
581 s = splnet(); | 597 598 IN_IFADDR_WLOCK(); |
582 TAILQ_REMOVE(&V_in_ifaddrhead, ia, ia_link); | 599 TAILQ_REMOVE(&V_in_ifaddrhead, ia, ia_link); |
583 ifa_free(&ia->ia_ifa); /* in_ifaddrhead */ | |
584 if (ia->ia_addr.sin_family == AF_INET) { 585 struct in_ifaddr *if_ia; 586 587 LIST_REMOVE(ia, ia_hash); | 600 if (ia->ia_addr.sin_family == AF_INET) { 601 struct in_ifaddr *if_ia; 602 603 LIST_REMOVE(ia, ia_hash); |
604 IN_IFADDR_WUNLOCK(); |
|
588 /* 589 * If this is the last IPv4 address configured on this 590 * interface, leave the all-hosts group. 591 * No state-change report need be transmitted. 592 */ 593 if_ia = NULL; 594 IFP_TO_IA(ifp, if_ia); 595 if (if_ia == NULL) { 596 ii = ((struct in_ifinfo *)ifp->if_afdata[AF_INET]); 597 IN_MULTI_LOCK(); 598 if (ii->ii_allhosts) { 599 (void)in_leavegroup_locked(ii->ii_allhosts, 600 NULL); 601 ii->ii_allhosts = NULL; 602 } 603 IN_MULTI_UNLOCK(); 604 } else 605 ifa_free(&if_ia->ia_ifa); | 605 /* 606 * If this is the last IPv4 address configured on this 607 * interface, leave the all-hosts group. 608 * No state-change report need be transmitted. 609 */ 610 if_ia = NULL; 611 IFP_TO_IA(ifp, if_ia); 612 if (if_ia == NULL) { 613 ii = ((struct in_ifinfo *)ifp->if_afdata[AF_INET]); 614 IN_MULTI_LOCK(); 615 if (ii->ii_allhosts) { 616 (void)in_leavegroup_locked(ii->ii_allhosts, 617 NULL); 618 ii->ii_allhosts = NULL; 619 } 620 IN_MULTI_UNLOCK(); 621 } else 622 ifa_free(&if_ia->ia_ifa); |
606 } 607 splx(s); | 623 } else 624 IN_IFADDR_WUNLOCK(); 625 ifa_free(&ia->ia_ifa); /* in_ifaddrhead */ |
608out: 609 if (ia != NULL) 610 ifa_free(&ia->ia_ifa); 611 return (error); 612} 613 614/* 615 * SIOC[GAD]LIFADDR. --- 190 unchanged lines hidden (view full) --- 806 struct rt_addrinfo info; 807 static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; 808 int s = splimp(), flags = RTF_UP, error = 0; 809 810 oldaddr = ia->ia_addr; 811 if (oldaddr.sin_family == AF_INET) 812 LIST_REMOVE(ia, ia_hash); 813 ia->ia_addr = *sin; | 626out: 627 if (ia != NULL) 628 ifa_free(&ia->ia_ifa); 629 return (error); 630} 631 632/* 633 * SIOC[GAD]LIFADDR. --- 190 unchanged lines hidden (view full) --- 824 struct rt_addrinfo info; 825 static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; 826 int s = splimp(), flags = RTF_UP, error = 0; 827 828 oldaddr = ia->ia_addr; 829 if (oldaddr.sin_family == AF_INET) 830 LIST_REMOVE(ia, ia_hash); 831 ia->ia_addr = *sin; |
814 if (ia->ia_addr.sin_family == AF_INET) | 832 if (ia->ia_addr.sin_family == AF_INET) { 833 IN_IFADDR_WLOCK(); |
815 LIST_INSERT_HEAD(INADDR_HASH(ia->ia_addr.sin_addr.s_addr), 816 ia, ia_hash); | 834 LIST_INSERT_HEAD(INADDR_HASH(ia->ia_addr.sin_addr.s_addr), 835 ia, ia_hash); |
836 IN_IFADDR_WUNLOCK(); 837 } |
|
817 /* 818 * Give the interface a chance to initialize 819 * if this is its first address, 820 * and to validate the address if necessary. 821 */ 822 if (ifp->if_ioctl != NULL) { 823 error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia); 824 if (error) { 825 splx(s); 826 /* LIST_REMOVE(ia, ia_hash) is done in in_control */ 827 ia->ia_addr = oldaddr; | 838 /* 839 * Give the interface a chance to initialize 840 * if this is its first address, 841 * and to validate the address if necessary. 842 */ 843 if (ifp->if_ioctl != NULL) { 844 error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia); 845 if (error) { 846 splx(s); 847 /* LIST_REMOVE(ia, ia_hash) is done in in_control */ 848 ia->ia_addr = oldaddr; |
849 IN_IFADDR_WLOCK(); |
|
828 if (ia->ia_addr.sin_family == AF_INET) 829 LIST_INSERT_HEAD(INADDR_HASH( 830 ia->ia_addr.sin_addr.s_addr), ia, ia_hash); 831 else 832 /* 833 * If oldaddr family is not AF_INET (e.g. 834 * interface has been just created) in_control 835 * does not call LIST_REMOVE, and we end up 836 * with bogus ia entries in hash 837 */ 838 LIST_REMOVE(ia, ia_hash); | 850 if (ia->ia_addr.sin_family == AF_INET) 851 LIST_INSERT_HEAD(INADDR_HASH( 852 ia->ia_addr.sin_addr.s_addr), ia, ia_hash); 853 else 854 /* 855 * If oldaddr family is not AF_INET (e.g. 856 * interface has been just created) in_control 857 * does not call LIST_REMOVE, and we end up 858 * with bogus ia entries in hash 859 */ 860 LIST_REMOVE(ia, ia_hash); |
861 IN_IFADDR_WUNLOCK(); |
|
839 return (error); 840 } 841 } 842 splx(s); 843 if (scrub) { 844 ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr; 845 in_ifscrub(ifp, ia); 846 ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; --- 91 unchanged lines hidden (view full) --- 938 prefix = target->ia_dstaddr.sin_addr; 939 mask.s_addr = 0; 940 } else { 941 prefix = target->ia_addr.sin_addr; 942 mask = target->ia_sockmask.sin_addr; 943 prefix.s_addr &= mask.s_addr; 944 } 945 | 862 return (error); 863 } 864 } 865 splx(s); 866 if (scrub) { 867 ia->ia_ifa.ifa_addr = (struct sockaddr *)&oldaddr; 868 in_ifscrub(ifp, ia); 869 ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; --- 91 unchanged lines hidden (view full) --- 961 prefix = target->ia_dstaddr.sin_addr; 962 mask.s_addr = 0; 963 } else { 964 prefix = target->ia_addr.sin_addr; 965 mask = target->ia_sockmask.sin_addr; 966 prefix.s_addr &= mask.s_addr; 967 } 968 |
969 IN_IFADDR_RLOCK(); |
|
946 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { 947 if (rtinitflags(ia)) { 948 p = ia->ia_addr.sin_addr; 949 950 if (prefix.s_addr != p.s_addr) 951 continue; 952 } else { 953 p = ia->ia_addr.sin_addr; --- 7 unchanged lines hidden (view full) --- 961 962 /* 963 * If we got a matching prefix route inserted by other 964 * interface address, we are done here. 965 */ 966 if (ia->ia_flags & IFA_ROUTE) { 967 if (V_sameprefixcarponly && 968 target->ia_ifp->if_type != IFT_CARP && | 970 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { 971 if (rtinitflags(ia)) { 972 p = ia->ia_addr.sin_addr; 973 974 if (prefix.s_addr != p.s_addr) 975 continue; 976 } else { 977 p = ia->ia_addr.sin_addr; --- 7 unchanged lines hidden (view full) --- 985 986 /* 987 * If we got a matching prefix route inserted by other 988 * interface address, we are done here. 989 */ 990 if (ia->ia_flags & IFA_ROUTE) { 991 if (V_sameprefixcarponly && 992 target->ia_ifp->if_type != IFT_CARP && |
969 ia->ia_ifp->if_type != IFT_CARP) | 993 ia->ia_ifp->if_type != IFT_CARP) { 994 IN_IFADDR_RUNLOCK(); |
970 return (EEXIST); | 995 return (EEXIST); |
971 else | 996 } else { 997 IN_IFADDR_RUNLOCK(); |
972 return (0); | 998 return (0); |
999 } |
|
973 } 974 } | 1000 } 1001 } |
1002 IN_IFADDR_RUNLOCK(); |
|
975 976 /* 977 * No-one seem to have this prefix route, so we try to insert it. 978 */ 979 error = rtinit(&target->ia_ifa, (int)RTM_ADD, flags); 980 if (!error) 981 target->ia_flags |= IFA_ROUTE; 982 return (error); --- 43 unchanged lines hidden (view full) --- 1026 else { 1027 prefix = target->ia_addr.sin_addr; 1028 mask = target->ia_sockmask.sin_addr; 1029 prefix.s_addr &= mask.s_addr; 1030 /* remove arp cache */ 1031 arp_ifscrub(target->ia_ifp, IA_SIN(target)->sin_addr.s_addr); 1032 } 1033 | 1003 1004 /* 1005 * No-one seem to have this prefix route, so we try to insert it. 1006 */ 1007 error = rtinit(&target->ia_ifa, (int)RTM_ADD, flags); 1008 if (!error) 1009 target->ia_flags |= IFA_ROUTE; 1010 return (error); --- 43 unchanged lines hidden (view full) --- 1054 else { 1055 prefix = target->ia_addr.sin_addr; 1056 mask = target->ia_sockmask.sin_addr; 1057 prefix.s_addr &= mask.s_addr; 1058 /* remove arp cache */ 1059 arp_ifscrub(target->ia_ifp, IA_SIN(target)->sin_addr.s_addr); 1060 } 1061 |
1062 IN_IFADDR_RLOCK(); |
|
1034 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { 1035 if (rtinitflags(ia)) 1036 p = ia->ia_dstaddr.sin_addr; 1037 else { 1038 p = ia->ia_addr.sin_addr; 1039 p.s_addr &= ia->ia_sockmask.sin_addr.s_addr; 1040 } 1041 --- 7 unchanged lines hidden (view full) --- 1049 * 1050 * XXX: a special case for carp(4) interface 1051 */ 1052 if ((ia->ia_flags & IFA_ROUTE) == 0 1053#ifdef DEV_CARP 1054 && (ia->ia_ifp->if_type != IFT_CARP) 1055#endif 1056 ) { | 1063 TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { 1064 if (rtinitflags(ia)) 1065 p = ia->ia_dstaddr.sin_addr; 1066 else { 1067 p = ia->ia_addr.sin_addr; 1068 p.s_addr &= ia->ia_sockmask.sin_addr.s_addr; 1069 } 1070 --- 7 unchanged lines hidden (view full) --- 1078 * 1079 * XXX: a special case for carp(4) interface 1080 */ 1081 if ((ia->ia_flags & IFA_ROUTE) == 0 1082#ifdef DEV_CARP 1083 && (ia->ia_ifp->if_type != IFT_CARP) 1084#endif 1085 ) { |
1086 IN_IFADDR_RUNLOCK(); |
|
1057 rtinit(&(target->ia_ifa), (int)RTM_DELETE, 1058 rtinitflags(target)); 1059 target->ia_flags &= ~IFA_ROUTE; 1060 1061 error = rtinit(&ia->ia_ifa, (int)RTM_ADD, 1062 rtinitflags(ia) | RTF_UP); 1063 if (error == 0) 1064 ia->ia_flags |= IFA_ROUTE; 1065 return (error); 1066 } 1067 } | 1087 rtinit(&(target->ia_ifa), (int)RTM_DELETE, 1088 rtinitflags(target)); 1089 target->ia_flags &= ~IFA_ROUTE; 1090 1091 error = rtinit(&ia->ia_ifa, (int)RTM_ADD, 1092 rtinitflags(ia) | RTF_UP); 1093 if (error == 0) 1094 ia->ia_flags |= IFA_ROUTE; 1095 return (error); 1096 } 1097 } |
1098 IN_IFADDR_RUNLOCK(); |
|
1068 1069 /* 1070 * remove all L2 entries on the given prefix 1071 */ 1072 bzero(&prefix0, sizeof(prefix0)); 1073 prefix0.sin_len = sizeof(prefix0); 1074 prefix0.sin_family = AF_INET; 1075 prefix0.sin_addr.s_addr = target->ia_subnet; --- 397 unchanged lines hidden --- | 1099 1100 /* 1101 * remove all L2 entries on the given prefix 1102 */ 1103 bzero(&prefix0, sizeof(prefix0)); 1104 prefix0.sin_len = sizeof(prefix0); 1105 prefix0.sin_family = AF_INET; 1106 prefix0.sin_addr.s_addr = target->ia_subnet; --- 397 unchanged lines hidden --- |