Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/scope6.c
| Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
| #define SCOPE6_LOCK_INIT() mtx_init(&scope6_lock, "scope6_lock", NULL, MTX_DEF) | #define SCOPE6_LOCK_INIT() mtx_init(&scope6_lock, "scope6_lock", NULL, MTX_DEF) | ||||
| #define SCOPE6_LOCK() mtx_lock(&scope6_lock) | #define SCOPE6_LOCK() mtx_lock(&scope6_lock) | ||||
| #define SCOPE6_UNLOCK() mtx_unlock(&scope6_lock) | #define SCOPE6_UNLOCK() mtx_unlock(&scope6_lock) | ||||
| #define SCOPE6_LOCK_ASSERT() mtx_assert(&scope6_lock, MA_OWNED) | #define SCOPE6_LOCK_ASSERT() mtx_assert(&scope6_lock, MA_OWNED) | ||||
| VNET_DEFINE_STATIC(struct scope6_id, sid_default); | VNET_DEFINE_STATIC(struct scope6_id, sid_default); | ||||
| #define V_sid_default VNET(sid_default) | #define V_sid_default VNET(sid_default) | ||||
| #define SID(ifp) ((ifp)->if_inet6->scope6_id) | #define SID(ifp) (&(ifp)->if_inet6->scope6_id) | ||||
| static int scope6_get(struct ifnet *, struct scope6_id *); | static int scope6_get(struct ifnet *, struct scope6_id *); | ||||
| static int scope6_set(struct ifnet *, struct scope6_id *); | static int scope6_set(struct ifnet *, struct scope6_id *); | ||||
| static int scope6_get_default(struct scope6_id *); | |||||
| void | void | ||||
| scope6_init(void) | scope6_init(void) | ||||
| { | { | ||||
| bzero(&V_sid_default, sizeof(V_sid_default)); | bzero(&V_sid_default, sizeof(V_sid_default)); | ||||
| if (!IS_DEFAULT_VNET(curvnet)) | if (!IS_DEFAULT_VNET(curvnet)) | ||||
| return; | return; | ||||
| SCOPE6_LOCK_INIT(); | SCOPE6_LOCK_INIT(); | ||||
| } | } | ||||
| struct scope6_id * | void | ||||
| scope6_ifattach(struct ifnet *ifp) | scope6_ifattach(struct ifnet *ifp) | ||||
| { | { | ||||
| struct scope6_id *sid; | struct scope6_id *sid = &ifp->if_inet6->scope6_id; | ||||
| sid = malloc(sizeof(*sid), M_IFADDR, M_WAITOK | M_ZERO); | |||||
| /* | /* | ||||
| * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard. | * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard. | ||||
| * Should we rather hardcode here? | * Should we rather hardcode here? | ||||
| */ | */ | ||||
| bzero(sid, sizeof(*sid)); | |||||
| sid->s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = ifp->if_index; | sid->s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = ifp->if_index; | ||||
| sid->s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = ifp->if_index; | sid->s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = ifp->if_index; | ||||
| return (sid); | |||||
| } | } | ||||
| void | |||||
| scope6_ifdetach(struct scope6_id *sid) | |||||
| { | |||||
| free(sid, M_IFADDR); | |||||
| } | |||||
| int | int | ||||
| scope6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) | scope6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) | ||||
| { | { | ||||
| struct in6_ifreq *ifr; | struct in6_ifreq *ifr; | ||||
| if (ifp->if_inet6 == NULL) | if (ifp->if_inet6 == NULL) | ||||
| return (EPFNOSUPPORT); | return (EPFNOSUPPORT); | ||||
| ▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | V_sid_default.s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = | ||||
| ifp->if_index; | ifp->if_index; | ||||
| } else { | } else { | ||||
| V_sid_default.s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = 0; | V_sid_default.s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = 0; | ||||
| V_sid_default.s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = 0; | V_sid_default.s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = 0; | ||||
| } | } | ||||
| SCOPE6_UNLOCK(); | SCOPE6_UNLOCK(); | ||||
| } | } | ||||
| int | static int | ||||
| scope6_get_default(struct scope6_id *idlist) | scope6_get_default(struct scope6_id *idlist) | ||||
| { | { | ||||
| SCOPE6_LOCK(); | SCOPE6_LOCK(); | ||||
| *idlist = V_sid_default; | *idlist = V_sid_default; | ||||
| SCOPE6_UNLOCK(); | SCOPE6_UNLOCK(); | ||||
| return (0); | return (0); | ||||
| ▲ Show 20 Lines • Show All 336 Lines • Show Last 20 Lines | |||||