Deleted Added
full compact
in6.c (191340) in6.c (191672)
1/*-
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * 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

--- 47 unchanged lines hidden (view full) ---

56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)in.c 8.2 (Berkeley) 11/15/93
61 */
62
63#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * 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

--- 47 unchanged lines hidden (view full) ---

56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 * @(#)in.c 8.2 (Berkeley) 11/15/93
61 */
62
63#include <sys/cdefs.h>
64__FBSDID("$FreeBSD: head/sys/netinet6/in6.c 191340 2009-04-20 22:45:21Z rwatson $");
64__FBSDID("$FreeBSD: head/sys/netinet6/in6.c 191672 2009-04-29 19:19:13Z bms $");
65
66#include "opt_inet.h"
67#include "opt_inet6.h"
68#include "opt_route.h"
69
70#include <sys/param.h>
71#include <sys/errno.h>
72#include <sys/jail.h>

--- 28 unchanged lines hidden (view full) ---

101#include <netinet6/nd6.h>
102#include <netinet6/mld6_var.h>
103#include <netinet6/ip6_mroute.h>
104#include <netinet6/in6_ifattach.h>
105#include <netinet6/scope6_var.h>
106#include <netinet6/in6_pcb.h>
107#include <netinet6/vinet6.h>
108
65
66#include "opt_inet.h"
67#include "opt_inet6.h"
68#include "opt_route.h"
69
70#include <sys/param.h>
71#include <sys/errno.h>
72#include <sys/jail.h>

--- 28 unchanged lines hidden (view full) ---

101#include <netinet6/nd6.h>
102#include <netinet6/mld6_var.h>
103#include <netinet6/ip6_mroute.h>
104#include <netinet6/in6_ifattach.h>
105#include <netinet6/scope6_var.h>
106#include <netinet6/in6_pcb.h>
107#include <netinet6/vinet6.h>
108
109MALLOC_DEFINE(M_IP6MADDR, "in6_multi", "internet multicast address");
110
111/*
112 * Definitions of some costant IP6 addresses.
113 */
114const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
115const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
116const struct in6_addr in6addr_nodelocal_allnodes =
117 IN6ADDR_NODELOCAL_ALLNODES_INIT;
118const struct in6_addr in6addr_linklocal_allnodes =
119 IN6ADDR_LINKLOCAL_ALLNODES_INIT;
120const struct in6_addr in6addr_linklocal_allrouters =
121 IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
109/*
110 * Definitions of some costant IP6 addresses.
111 */
112const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
113const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
114const struct in6_addr in6addr_nodelocal_allnodes =
115 IN6ADDR_NODELOCAL_ALLNODES_INIT;
116const struct in6_addr in6addr_linklocal_allnodes =
117 IN6ADDR_LINKLOCAL_ALLNODES_INIT;
118const struct in6_addr in6addr_linklocal_allrouters =
119 IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
120const struct in6_addr in6addr_linklocal_allv2routers =
121 IN6ADDR_LINKLOCAL_ALLV2ROUTERS_INIT;
122
123const struct in6_addr in6mask0 = IN6MASK0;
124const struct in6_addr in6mask32 = IN6MASK32;
125const struct in6_addr in6mask64 = IN6MASK64;
126const struct in6_addr in6mask96 = IN6MASK96;
127const struct in6_addr in6mask128 = IN6MASK128;
128
129const struct sockaddr_in6 sa6_any =
130 { sizeof(sa6_any), AF_INET6, 0, 0, IN6ADDR_ANY_INIT, 0 };
131
132static int in6_lifaddr_ioctl __P((struct socket *, u_long, caddr_t,
133 struct ifnet *, struct thread *));
134static int in6_ifinit __P((struct ifnet *, struct in6_ifaddr *,
135 struct sockaddr_in6 *, int));
136static void in6_unlink_ifa(struct in6_ifaddr *, struct ifnet *);
137
122
123const struct in6_addr in6mask0 = IN6MASK0;
124const struct in6_addr in6mask32 = IN6MASK32;
125const struct in6_addr in6mask64 = IN6MASK64;
126const struct in6_addr in6mask96 = IN6MASK96;
127const struct in6_addr in6mask128 = IN6MASK128;
128
129const struct sockaddr_in6 sa6_any =
130 { sizeof(sa6_any), AF_INET6, 0, 0, IN6ADDR_ANY_INIT, 0 };
131
132static int in6_lifaddr_ioctl __P((struct socket *, u_long, caddr_t,
133 struct ifnet *, struct thread *));
134static int in6_ifinit __P((struct ifnet *, struct in6_ifaddr *,
135 struct sockaddr_in6 *, int));
136static void in6_unlink_ifa(struct in6_ifaddr *, struct ifnet *);
137
138struct in6_multihead in6_multihead; /* XXX BSS initialization */
139int (*faithprefix_p)(struct in6_addr *);
140
141
142
143int
144in6_mask2len(struct in6_addr *mask, u_char *lim0)
145{
146 int x = 0, y;

--- 958 unchanged lines hidden (view full) ---

1105 if ((flags & IN6_IFAUPDATE_DADDELAY)) {
1106 /*
1107 * We need to impose a delay before sending an NS
1108 * for DAD. Check if we also needed a delay for the
1109 * corresponding MLD message. If we did, the delay
1110 * should be larger than the MLD delay (this could be
1111 * relaxed a bit, but this simple logic is at least
1112 * safe).
138int (*faithprefix_p)(struct in6_addr *);
139
140
141
142int
143in6_mask2len(struct in6_addr *mask, u_char *lim0)
144{
145 int x = 0, y;

--- 958 unchanged lines hidden (view full) ---

1104 if ((flags & IN6_IFAUPDATE_DADDELAY)) {
1105 /*
1106 * We need to impose a delay before sending an NS
1107 * for DAD. Check if we also needed a delay for the
1108 * corresponding MLD message. If we did, the delay
1109 * should be larger than the MLD delay (this could be
1110 * relaxed a bit, but this simple logic is at least
1111 * safe).
1112 * XXX: Break data hiding guidelines and look at
1113 * state for the solicited multicast group.
1113 */
1114 mindelay = 0;
1115 if (in6m_sol != NULL &&
1114 */
1115 mindelay = 0;
1116 if (in6m_sol != NULL &&
1116 in6m_sol->in6m_state == MLD_REPORTPENDING) {
1117 in6m_sol->in6m_state == MLD_REPORTING_MEMBER) {
1117 mindelay = in6m_sol->in6m_timer;
1118 }
1119 maxdelay = MAX_RTR_SOLICITATION_DELAY * hz;
1120 if (maxdelay - mindelay == 0)
1121 delay = 0;
1122 else {
1123 delay =
1124 (arc4random() % (maxdelay - mindelay)) +

--- 460 unchanged lines hidden (view full) ---

1585 ln->ln_state = ND6_LLINFO_REACHABLE;
1586 LLE_WUNLOCK(ln);
1587 }
1588 }
1589
1590 return (error);
1591}
1592
1118 mindelay = in6m_sol->in6m_timer;
1119 }
1120 maxdelay = MAX_RTR_SOLICITATION_DELAY * hz;
1121 if (maxdelay - mindelay == 0)
1122 delay = 0;
1123 else {
1124 delay =
1125 (arc4random() % (maxdelay - mindelay)) +

--- 460 unchanged lines hidden (view full) ---

1586 ln->ln_state = ND6_LLINFO_REACHABLE;
1587 LLE_WUNLOCK(ln);
1588 }
1589 }
1590
1591 return (error);
1592}
1593
1593struct in6_multi_mship *
1594in6_joingroup(struct ifnet *ifp, struct in6_addr *addr,
1595 int *errorp, int delay)
1596{
1597 struct in6_multi_mship *imm;
1598
1599 imm = malloc(sizeof(*imm), M_IP6MADDR, M_NOWAIT);
1600 if (!imm) {
1601 *errorp = ENOBUFS;
1602 return NULL;
1603 }
1604 imm->i6mm_maddr = in6_addmulti(addr, ifp, errorp, delay);
1605 if (!imm->i6mm_maddr) {
1606 /* *errorp is alrady set */
1607 free(imm, M_IP6MADDR);
1608 return NULL;
1609 }
1610 return imm;
1611}
1612
1613int
1614in6_leavegroup(struct in6_multi_mship *imm)
1615{
1616
1617 if (imm->i6mm_maddr)
1618 in6_delmulti(imm->i6mm_maddr);
1619 free(imm, M_IP6MADDR);
1620 return 0;
1621}
1622
1623/*
1624 * Find an IPv6 interface link-local address specific to an interface.
1625 */
1626struct in6_ifaddr *
1627in6ifa_ifpforlinklocal(struct ifnet *ifp, int ignoreflags)
1628{
1629 struct ifaddr *ifa;
1630

--- 692 unchanged lines hidden (view full) ---

2323 ext->lltable = lltable_init(ifp, AF_INET6);
2324 if (ext->lltable != NULL) {
2325 ext->lltable->llt_new = in6_lltable_new;
2326 ext->lltable->llt_free = in6_lltable_free;
2327 ext->lltable->llt_rtcheck = in6_lltable_rtcheck;
2328 ext->lltable->llt_lookup = in6_lltable_lookup;
2329 ext->lltable->llt_dump = in6_lltable_dump;
2330 }
1594/*
1595 * Find an IPv6 interface link-local address specific to an interface.
1596 */
1597struct in6_ifaddr *
1598in6ifa_ifpforlinklocal(struct ifnet *ifp, int ignoreflags)
1599{
1600 struct ifaddr *ifa;
1601

--- 692 unchanged lines hidden (view full) ---

2294 ext->lltable = lltable_init(ifp, AF_INET6);
2295 if (ext->lltable != NULL) {
2296 ext->lltable->llt_new = in6_lltable_new;
2297 ext->lltable->llt_free = in6_lltable_free;
2298 ext->lltable->llt_rtcheck = in6_lltable_rtcheck;
2299 ext->lltable->llt_lookup = in6_lltable_lookup;
2300 ext->lltable->llt_dump = in6_lltable_dump;
2301 }
2302
2303 ext->mld_ifinfo = mld_domifattach(ifp);
2304
2331 return ext;
2332}
2333
2334void
2335in6_domifdetach(struct ifnet *ifp, void *aux)
2336{
2337 struct in6_ifextra *ext = (struct in6_ifextra *)aux;
2338
2305 return ext;
2306}
2307
2308void
2309in6_domifdetach(struct ifnet *ifp, void *aux)
2310{
2311 struct in6_ifextra *ext = (struct in6_ifextra *)aux;
2312
2313 mld_domifdetach(ifp);
2339 scope6_ifdetach(ext->scope6_id);
2340 nd6_ifdetach(ext->nd_ifinfo);
2341 lltable_free(ext->lltable);
2342 free(ext->in6_ifstat, M_IFADDR);
2343 free(ext->icmp6_ifstat, M_IFADDR);
2344 free(ext, M_IFADDR);
2345}
2346

--- 59 unchanged lines hidden ---
2314 scope6_ifdetach(ext->scope6_id);
2315 nd6_ifdetach(ext->nd_ifinfo);
2316 lltable_free(ext->lltable);
2317 free(ext->in6_ifstat, M_IFADDR);
2318 free(ext->icmp6_ifstat, M_IFADDR);
2319 free(ext, M_IFADDR);
2320}
2321

--- 59 unchanged lines hidden ---