2021-09-21 17:59:14 +03:00
|
|
|
/* $NetBSD: ddp_usrreq.c,v 1.75 2021/09/21 15:01:59 christos Exp $ */
|
1997-04-03 01:31:01 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1990,1991 Regents of The University of Michigan.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software and
|
|
|
|
* its documentation for any purpose and without fee is hereby granted,
|
|
|
|
* provided that the above copyright notice appears in all copies and
|
|
|
|
* that both that copyright notice and this permission notice appear
|
|
|
|
* in supporting documentation, and that the name of The University
|
|
|
|
* of Michigan not be used in advertising or publicity pertaining to
|
|
|
|
* distribution of the software without specific, written prior
|
|
|
|
* permission. This software is supplied as is without expressed or
|
|
|
|
* implied warranties of any kind.
|
|
|
|
*
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
*
|
|
|
|
* Research Systems Unix Group
|
|
|
|
* The University of Michigan
|
|
|
|
* c/o Wesley Craig
|
|
|
|
* 535 W. William Street
|
|
|
|
* Ann Arbor, Michigan
|
|
|
|
* +1-313-764-2278
|
|
|
|
* netatalk@umich.edu
|
|
|
|
*/
|
|
|
|
|
2001-11-13 03:00:58 +03:00
|
|
|
#include <sys/cdefs.h>
|
2021-09-21 17:59:14 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.75 2021/09/21 15:01:59 christos Exp $");
|
2003-06-23 15:00:59 +04:00
|
|
|
|
|
|
|
#include "opt_mbuftrace.h"
|
2018-02-17 22:10:18 +03:00
|
|
|
#include "opt_atalk.h"
|
2001-11-13 03:00:58 +03:00
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
#include <sys/param.h>
|
2001-11-15 12:47:59 +03:00
|
|
|
#include <sys/errno.h>
|
1997-04-03 01:31:01 +04:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/ioctl.h>
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
#include <sys/queue.h>
|
1997-04-03 01:31:01 +04:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/protosw.h>
|
2006-05-15 01:19:33 +04:00
|
|
|
#include <sys/kauth.h>
|
2014-05-19 06:51:24 +04:00
|
|
|
#include <sys/kmem.h>
|
2008-04-23 19:17:42 +04:00
|
|
|
#include <sys/sysctl.h>
|
1997-04-03 01:31:01 +04:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <net/if_ether.h>
|
2008-04-23 19:17:42 +04:00
|
|
|
#include <net/net_stats.h>
|
1997-04-03 01:31:01 +04:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include <netatalk/at.h>
|
|
|
|
#include <netatalk/at_var.h>
|
|
|
|
#include <netatalk/ddp_var.h>
|
2008-04-23 19:17:42 +04:00
|
|
|
#include <netatalk/ddp_private.h>
|
1997-04-03 01:31:01 +04:00
|
|
|
#include <netatalk/aarp.h>
|
|
|
|
#include <netatalk/at_extern.h>
|
|
|
|
|
2009-03-14 17:45:51 +03:00
|
|
|
static void at_pcbdisconnect(struct ddpcb *);
|
2015-04-25 01:32:37 +03:00
|
|
|
static void at_sockaddr(struct ddpcb *, struct sockaddr_at *);
|
2015-04-03 23:01:07 +03:00
|
|
|
static int at_pcbsetaddr(struct ddpcb *, struct sockaddr_at *);
|
2015-04-25 02:36:48 +03:00
|
|
|
static int at_pcbconnect(struct ddpcb *, struct sockaddr_at *);
|
2014-05-19 06:51:24 +04:00
|
|
|
static void ddp_detach(struct socket *);
|
1997-04-03 01:31:01 +04:00
|
|
|
|
2002-05-13 01:43:23 +04:00
|
|
|
struct ifqueue atintrq1, atintrq2;
|
1997-04-03 01:31:01 +04:00
|
|
|
struct ddpcb *ddp_ports[ATPORT_LAST];
|
|
|
|
struct ddpcb *ddpcb = NULL;
|
2008-04-23 19:17:42 +04:00
|
|
|
percpu_t *ddpstat_percpu;
|
1997-04-03 01:31:01 +04:00
|
|
|
struct at_ifaddrhead at_ifaddr; /* Here as inited in this file */
|
|
|
|
u_long ddp_sendspace = DDP_MAXSZ; /* Max ddp size + 1 (ddp_type) */
|
1997-04-29 17:44:47 +04:00
|
|
|
u_long ddp_recvspace = 25 * (587 + sizeof(struct sockaddr_at));
|
1997-04-03 01:31:01 +04:00
|
|
|
|
2003-02-26 10:53:04 +03:00
|
|
|
#ifdef MBUFTRACE
|
2006-10-11 01:49:14 +04:00
|
|
|
struct mowner atalk_rx_mowner = MOWNER_INIT("atalk", "rx");
|
|
|
|
struct mowner atalk_tx_mowner = MOWNER_INIT("atalk", "tx");
|
2003-02-26 10:53:04 +03:00
|
|
|
#endif
|
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
static void
|
2015-04-25 01:32:37 +03:00
|
|
|
at_sockaddr(struct ddpcb *ddp, struct sockaddr_at *addr)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
|
|
|
|
2015-04-25 01:32:37 +03:00
|
|
|
*addr = ddp->ddp_lsat;
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-04-03 23:01:07 +03:00
|
|
|
at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr_at *sat)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
2015-04-03 23:01:07 +03:00
|
|
|
struct sockaddr_at lsat;
|
1997-04-03 01:31:01 +04:00
|
|
|
struct at_ifaddr *aa;
|
|
|
|
struct ddpcb *ddpp;
|
|
|
|
|
|
|
|
if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT) { /* shouldn't be bound */
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2015-04-03 23:01:07 +03:00
|
|
|
if (NULL != sat) { /* validate passed address */
|
1997-04-03 01:31:01 +04:00
|
|
|
|
|
|
|
if (sat->sat_family != AF_APPLETALK)
|
|
|
|
return (EAFNOSUPPORT);
|
2019-11-29 20:40:16 +03:00
|
|
|
if (sat->sat_len != sizeof(*sat))
|
|
|
|
return EINVAL;
|
1997-04-03 01:31:01 +04:00
|
|
|
|
|
|
|
if (sat->sat_addr.s_node != ATADDR_ANYNODE ||
|
|
|
|
sat->sat_addr.s_net != ATADDR_ANYNET) {
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
TAILQ_FOREACH(aa, &at_ifaddr, aa_list) {
|
1997-04-03 01:31:01 +04:00
|
|
|
if ((sat->sat_addr.s_net ==
|
|
|
|
AA_SAT(aa)->sat_addr.s_net) &&
|
|
|
|
(sat->sat_addr.s_node ==
|
|
|
|
AA_SAT(aa)->sat_addr.s_node))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!aa)
|
|
|
|
return (EADDRNOTAVAIL);
|
|
|
|
}
|
|
|
|
if (sat->sat_port != ATADDR_ANYPORT) {
|
2009-04-17 01:37:17 +04:00
|
|
|
int error;
|
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
if (sat->sat_port < ATPORT_FIRST ||
|
|
|
|
sat->sat_port >= ATPORT_LAST)
|
|
|
|
return (EINVAL);
|
|
|
|
|
2014-07-24 19:12:03 +04:00
|
|
|
if (sat->sat_port < ATPORT_RESERVED &&
|
2021-09-21 17:59:14 +03:00
|
|
|
(error = kauth_authorize_network(
|
|
|
|
kauth_cred_get(),
|
2009-04-17 01:37:17 +04:00
|
|
|
KAUTH_NETWORK_BIND, KAUTH_REQ_NETWORK_BIND_PRIVPORT,
|
|
|
|
ddpcb->ddp_socket, sat, NULL)) != 0)
|
|
|
|
return (error);
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
} else {
|
2009-03-18 19:00:08 +03:00
|
|
|
memset((void *) & lsat, 0, sizeof(struct sockaddr_at));
|
1997-04-03 01:31:01 +04:00
|
|
|
lsat.sat_len = sizeof(struct sockaddr_at);
|
|
|
|
lsat.sat_addr.s_node = ATADDR_ANYNODE;
|
|
|
|
lsat.sat_addr.s_net = ATADDR_ANYNET;
|
|
|
|
lsat.sat_family = AF_APPLETALK;
|
|
|
|
sat = &lsat;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sat->sat_addr.s_node == ATADDR_ANYNODE &&
|
|
|
|
sat->sat_addr.s_net == ATADDR_ANYNET) {
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
if (TAILQ_EMPTY(&at_ifaddr))
|
|
|
|
return EADDRNOTAVAIL;
|
|
|
|
sat->sat_addr = AA_SAT(TAILQ_FIRST(&at_ifaddr))->sat_addr;
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
ddp->ddp_lsat = *sat;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Choose port.
|
|
|
|
*/
|
|
|
|
if (sat->sat_port == ATADDR_ANYPORT) {
|
|
|
|
for (sat->sat_port = ATPORT_RESERVED;
|
|
|
|
sat->sat_port < ATPORT_LAST; sat->sat_port++) {
|
|
|
|
if (ddp_ports[sat->sat_port - 1] == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (sat->sat_port == ATPORT_LAST) {
|
|
|
|
return (EADDRNOTAVAIL);
|
|
|
|
}
|
|
|
|
ddp->ddp_lsat.sat_port = sat->sat_port;
|
|
|
|
ddp_ports[sat->sat_port - 1] = ddp;
|
|
|
|
} else {
|
|
|
|
for (ddpp = ddp_ports[sat->sat_port - 1]; ddpp;
|
|
|
|
ddpp = ddpp->ddp_pnext) {
|
2005-02-27 01:45:09 +03:00
|
|
|
if (ddpp->ddp_lsat.sat_addr.s_net ==
|
1997-04-03 01:31:01 +04:00
|
|
|
sat->sat_addr.s_net &&
|
|
|
|
ddpp->ddp_lsat.sat_addr.s_node ==
|
|
|
|
sat->sat_addr.s_node)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ddpp != NULL)
|
|
|
|
return (EADDRINUSE);
|
|
|
|
|
|
|
|
ddp->ddp_pnext = ddp_ports[sat->sat_port - 1];
|
|
|
|
ddp_ports[sat->sat_port - 1] = ddp;
|
|
|
|
if (ddp->ddp_pnext)
|
|
|
|
ddp->ddp_pnext->ddp_pprev = ddp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-04-25 02:36:48 +03:00
|
|
|
at_pcbconnect(struct ddpcb *ddp, struct sockaddr_at *sat)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
2007-12-20 22:53:29 +03:00
|
|
|
struct rtentry *rt;
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
const struct sockaddr_at *cdst;
|
KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.
Cosmetic: don't open-code TAILQ_FOREACH().
Cosmetic: change types of variables to avoid oodles of casts: in
in6_src.c, avoid casts by changing several route_in6 pointers
to struct route pointers. Remove unnecessary casts to caddr_t
elsewhere.
Pave the way for eliminating address family-specific route caches:
soon, struct route will not embed a sockaddr, but it will hold
a reference to an external sockaddr, instead. We will set the
destination sockaddr using rtcache_setdst(). (I created a stub
for it, but it isn't used anywhere, yet.) rtcache_free() will
free the sockaddr. I have extracted from rtcache_free() a helper
subroutine, rtcache_clear(). rtcache_clear() will "forget" a
cached route, but it will not forget the destination by releasing
the sockaddr. I use rtcache_clear() instead of rtcache_free()
in rtcache_update(), because rtcache_update() is not supposed
to forget the destination.
Constify:
1 Introduce const accessor for route->ro_dst, rtcache_getdst().
2 Constify the 'dst' argument to ifnet->if_output(). This
led me to constify a lot of code called by output routines.
3 Constify the sockaddr argument to protosw->pr_ctlinput. This
led me to constify a lot of code called by ctlinput routines.
4 Introduce const macros for converting from a generic sockaddr
to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
satocsin, et cetera.
2007-02-18 01:34:07 +03:00
|
|
|
struct route *ro;
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
struct at_ifaddr *aa;
|
1997-04-03 01:31:01 +04:00
|
|
|
struct ifnet *ifp;
|
|
|
|
u_short hintnet = 0, net;
|
|
|
|
|
2019-02-24 10:20:33 +03:00
|
|
|
if (sat->sat_family != AF_APPLETALK)
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
return EAFNOSUPPORT;
|
2019-02-24 10:20:33 +03:00
|
|
|
if (sat->sat_len != sizeof(*sat))
|
|
|
|
return EINVAL;
|
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
/*
|
|
|
|
* Under phase 2, network 0 means "the network". We take "the
|
|
|
|
* network" to mean the network the control block is bound to.
|
|
|
|
* If the control block is not bound, there is an error.
|
|
|
|
*/
|
|
|
|
if (sat->sat_addr.s_net == ATADDR_ANYNET
|
|
|
|
&& sat->sat_addr.s_node != ATADDR_ANYNODE) {
|
|
|
|
if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT) {
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
return EADDRNOTAVAIL;
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
hintnet = ddp->ddp_lsat.sat_addr.s_net;
|
|
|
|
}
|
|
|
|
ro = &ddp->ddp_route;
|
|
|
|
/*
|
|
|
|
* If we've got an old route for this pcb, check that it is valid.
|
|
|
|
* If we've changed our address, we may have an old "good looking"
|
|
|
|
* route here. Attempt to detect it.
|
|
|
|
*/
|
2008-01-12 05:58:58 +03:00
|
|
|
if ((rt = rtcache_validate(ro)) != NULL ||
|
|
|
|
(rt = rtcache_update(ro, 1)) != NULL) {
|
1997-04-03 01:31:01 +04:00
|
|
|
if (hintnet) {
|
|
|
|
net = hintnet;
|
|
|
|
} else {
|
|
|
|
net = sat->sat_addr.s_net;
|
|
|
|
}
|
2007-12-20 22:53:29 +03:00
|
|
|
if ((ifp = rt->rt_ifp) != NULL) {
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
TAILQ_FOREACH(aa, &at_ifaddr, aa_list) {
|
1997-04-03 01:31:01 +04:00
|
|
|
if (aa->aa_ifp == ifp &&
|
|
|
|
ntohs(net) >= ntohs(aa->aa_firstnet) &&
|
|
|
|
ntohs(net) <= ntohs(aa->aa_lastnet)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
} else
|
|
|
|
aa = NULL;
|
|
|
|
cdst = satocsat(rtcache_getdst(ro));
|
|
|
|
if (aa == NULL || (cdst->sat_addr.s_net !=
|
1997-04-03 01:31:01 +04:00
|
|
|
(hintnet ? hintnet : sat->sat_addr.s_net) ||
|
2008-01-14 07:12:40 +03:00
|
|
|
cdst->sat_addr.s_node != sat->sat_addr.s_node)) {
|
2016-12-08 08:16:33 +03:00
|
|
|
rtcache_unref(rt, ro);
|
2006-12-16 00:18:52 +03:00
|
|
|
rtcache_free(ro);
|
2008-01-14 07:12:40 +03:00
|
|
|
rt = NULL;
|
|
|
|
}
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If we've got no route for this interface, try to find one.
|
|
|
|
*/
|
2008-01-14 07:12:40 +03:00
|
|
|
if (rt == NULL) {
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
union {
|
|
|
|
struct sockaddr dst;
|
|
|
|
struct sockaddr_at dsta;
|
|
|
|
} u;
|
|
|
|
|
|
|
|
sockaddr_at_init(&u.dsta, &sat->sat_addr, 0);
|
|
|
|
if (hintnet)
|
|
|
|
u.dsta.sat_addr.s_net = hintnet;
|
2008-01-28 21:28:31 +03:00
|
|
|
rt = rtcache_lookup(ro, &u.dst);
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Make sure any route that we have has a valid interface.
|
|
|
|
*/
|
2008-01-10 11:04:18 +03:00
|
|
|
if (rt != NULL && (ifp = rt->rt_ifp) != NULL) {
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
TAILQ_FOREACH(aa, &at_ifaddr, aa_list) {
|
|
|
|
if (aa->aa_ifp == ifp)
|
1997-04-03 01:31:01 +04:00
|
|
|
break;
|
|
|
|
}
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
} else
|
|
|
|
aa = NULL;
|
2016-12-08 08:16:33 +03:00
|
|
|
rtcache_unref(rt, ro);
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
if (aa == NULL)
|
|
|
|
return ENETUNREACH;
|
1997-04-03 01:31:01 +04:00
|
|
|
ddp->ddp_fsat = *sat;
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
if (ddp->ddp_lsat.sat_port == ATADDR_ANYPORT)
|
2014-07-24 19:12:03 +04:00
|
|
|
return at_pcbsetaddr(ddp, NULL);
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
return 0;
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-03-14 18:35:58 +03:00
|
|
|
at_pcbdisconnect(struct ddpcb *ddp)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
|
|
|
ddp->ddp_fsat.sat_addr.s_net = ATADDR_ANYNET;
|
|
|
|
ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
|
|
|
|
ddp->ddp_fsat.sat_port = ATADDR_ANYPORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-05-19 06:51:24 +04:00
|
|
|
ddp_attach(struct socket *so, int proto)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
2014-05-19 06:51:24 +04:00
|
|
|
struct ddpcb *ddp;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
KASSERT(sotoddpcb(so) == NULL);
|
|
|
|
sosetlock(so);
|
|
|
|
#ifdef MBUFTRACE
|
|
|
|
so->so_rcv.sb_mowner = &atalk_rx_mowner;
|
|
|
|
so->so_snd.sb_mowner = &atalk_tx_mowner;
|
|
|
|
#endif
|
|
|
|
error = soreserve(so, ddp_sendspace, ddp_recvspace);
|
|
|
|
if (error) {
|
|
|
|
return error;
|
|
|
|
}
|
1997-04-03 01:31:01 +04:00
|
|
|
|
2014-05-19 06:51:24 +04:00
|
|
|
ddp = kmem_zalloc(sizeof(*ddp), KM_SLEEP);
|
1997-04-03 01:31:01 +04:00
|
|
|
ddp->ddp_lsat.sat_port = ATADDR_ANYPORT;
|
|
|
|
|
|
|
|
ddp->ddp_next = ddpcb;
|
|
|
|
ddp->ddp_prev = NULL;
|
|
|
|
ddp->ddp_pprev = NULL;
|
|
|
|
ddp->ddp_pnext = NULL;
|
|
|
|
if (ddpcb) {
|
|
|
|
ddpcb->ddp_prev = ddp;
|
|
|
|
}
|
|
|
|
ddpcb = ddp;
|
|
|
|
|
|
|
|
ddp->ddp_socket = so;
|
2014-05-19 06:51:24 +04:00
|
|
|
so->so_pcb = ddp;
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
return 0;
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-05-19 06:51:24 +04:00
|
|
|
ddp_detach(struct socket *so)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
2014-05-19 06:51:24 +04:00
|
|
|
struct ddpcb *ddp = sotoddpcb(so);
|
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
soisdisconnected(so);
|
2014-05-19 06:51:24 +04:00
|
|
|
so->so_pcb = NULL;
|
2008-04-24 15:38:36 +04:00
|
|
|
/* sofree drops the lock */
|
1997-04-03 01:31:01 +04:00
|
|
|
sofree(so);
|
2008-04-24 15:38:36 +04:00
|
|
|
mutex_enter(softnet_lock);
|
1997-04-03 01:31:01 +04:00
|
|
|
|
|
|
|
/* remove ddp from ddp_ports list */
|
|
|
|
if (ddp->ddp_lsat.sat_port != ATADDR_ANYPORT &&
|
|
|
|
ddp_ports[ddp->ddp_lsat.sat_port - 1] != NULL) {
|
|
|
|
if (ddp->ddp_pprev != NULL) {
|
|
|
|
ddp->ddp_pprev->ddp_pnext = ddp->ddp_pnext;
|
|
|
|
} else {
|
|
|
|
ddp_ports[ddp->ddp_lsat.sat_port - 1] = ddp->ddp_pnext;
|
|
|
|
}
|
|
|
|
if (ddp->ddp_pnext != NULL) {
|
|
|
|
ddp->ddp_pnext->ddp_pprev = ddp->ddp_pprev;
|
|
|
|
}
|
|
|
|
}
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
rtcache_free(&ddp->ddp_route);
|
1997-04-03 01:31:01 +04:00
|
|
|
if (ddp->ddp_prev) {
|
|
|
|
ddp->ddp_prev->ddp_next = ddp->ddp_next;
|
|
|
|
} else {
|
|
|
|
ddpcb = ddp->ddp_next;
|
|
|
|
}
|
|
|
|
if (ddp->ddp_next) {
|
|
|
|
ddp->ddp_next->ddp_prev = ddp->ddp_prev;
|
|
|
|
}
|
2014-05-19 06:51:24 +04:00
|
|
|
kmem_free(ddp, sizeof(*ddp));
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 18:41:42 +04:00
|
|
|
static int
|
2015-04-25 01:32:37 +03:00
|
|
|
ddp_accept(struct socket *so, struct sockaddr *nam)
|
2014-07-09 18:41:42 +04:00
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2014-07-24 19:12:03 +04:00
|
|
|
static int
|
2015-04-03 23:01:07 +03:00
|
|
|
ddp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l)
|
2014-07-24 19:12:03 +04:00
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
KASSERT(sotoddpcb(so) != NULL);
|
|
|
|
|
2015-04-03 23:01:07 +03:00
|
|
|
return at_pcbsetaddr(sotoddpcb(so), (struct sockaddr_at *)nam);
|
2014-07-24 19:12:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-08-05 09:24:26 +04:00
|
|
|
ddp_listen(struct socket *so, struct lwp *l)
|
2014-07-24 19:12:03 +04:00
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2014-07-30 14:04:25 +04:00
|
|
|
static int
|
2015-05-02 20:18:03 +03:00
|
|
|
ddp_connect(struct socket *so, struct sockaddr *nam, struct lwp *l)
|
2014-07-30 14:04:25 +04:00
|
|
|
{
|
|
|
|
struct ddpcb *ddp = sotoddpcb(so);
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
KASSERT(ddp != NULL);
|
|
|
|
KASSERT(nam != NULL);
|
|
|
|
|
|
|
|
if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT)
|
|
|
|
return EISCONN;
|
2015-05-02 20:18:03 +03:00
|
|
|
error = at_pcbconnect(ddp, (struct sockaddr_at *)nam);
|
2014-07-30 14:04:25 +04:00
|
|
|
if (error == 0)
|
|
|
|
soisconnected(so);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2014-08-09 09:33:00 +04:00
|
|
|
static int
|
|
|
|
ddp_connect2(struct socket *so, struct socket *so2)
|
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions
xxx_disconnect(struct socket *)
xxx_shutdown(struct socket *)
xxx_abort(struct socket *)
- always KASSERT(solocked(so)) even if not implemented
- replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
with calls to pr_{disconnect,shutdown,abort}() respectively
rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().
- {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
- {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
- unp_shutdown() -> unp_shutdown1()
patch reviewed by rmind
2014-07-31 07:39:35 +04:00
|
|
|
static int
|
|
|
|
ddp_disconnect(struct socket *so)
|
|
|
|
{
|
|
|
|
struct ddpcb *ddp = sotoddpcb(so);
|
|
|
|
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
KASSERT(ddp != NULL);
|
|
|
|
|
|
|
|
if (ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE)
|
|
|
|
return ENOTCONN;
|
|
|
|
|
|
|
|
at_pcbdisconnect(ddp);
|
|
|
|
soisdisconnected(so);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ddp_shutdown(struct socket *so)
|
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
socantsendmore(so);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ddp_abort(struct socket *so)
|
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
soisdisconnected(so);
|
|
|
|
ddp_detach(so);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-22 12:10:18 +04:00
|
|
|
static int
|
2014-07-01 09:49:18 +04:00
|
|
|
ddp_ioctl(struct socket *so, u_long cmd, void *addr, struct ifnet *ifp)
|
2014-06-22 12:10:18 +04:00
|
|
|
{
|
2014-07-01 09:49:18 +04:00
|
|
|
return at_control(cmd, addr, ifp);
|
2014-06-22 12:10:18 +04:00
|
|
|
}
|
|
|
|
|
2014-07-06 07:33:33 +04:00
|
|
|
static int
|
|
|
|
ddp_stat(struct socket *so, struct stat *ub)
|
|
|
|
{
|
2014-07-07 21:13:56 +04:00
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
2014-07-07 19:13:21 +04:00
|
|
|
/* stat: don't bother with a blocksize. */
|
|
|
|
return 0;
|
2014-07-06 07:33:33 +04:00
|
|
|
}
|
|
|
|
|
* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).
- KASSERT(solocked(so)) always in new functions even if request
is not implemented
- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.
* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()
- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.
* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).
- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()
* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).
- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()
note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.
patch reviewed by rmind
welcome to 6.99.47
2014-07-09 08:54:03 +04:00
|
|
|
static int
|
2015-04-25 01:32:37 +03:00
|
|
|
ddp_peeraddr(struct socket *so, struct sockaddr *nam)
|
* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).
- KASSERT(solocked(so)) always in new functions even if request
is not implemented
- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.
* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()
- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.
* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).
- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()
* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).
- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()
note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.
patch reviewed by rmind
welcome to 6.99.47
2014-07-09 08:54:03 +04:00
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2015-04-25 01:32:37 +03:00
|
|
|
ddp_sockaddr(struct socket *so, struct sockaddr *nam)
|
* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).
- KASSERT(solocked(so)) always in new functions even if request
is not implemented
- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.
* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()
- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.
* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).
- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()
* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).
- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()
note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.
patch reviewed by rmind
welcome to 6.99.47
2014-07-09 08:54:03 +04:00
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
KASSERT(sotoddpcb(so) != NULL);
|
|
|
|
KASSERT(nam != NULL);
|
|
|
|
|
2015-04-25 01:32:37 +03:00
|
|
|
at_sockaddr(sotoddpcb(so), (struct sockaddr_at *)nam);
|
* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).
- KASSERT(solocked(so)) always in new functions even if request
is not implemented
- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.
* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()
- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.
* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).
- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()
* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).
- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()
note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.
patch reviewed by rmind
welcome to 6.99.47
2014-07-09 08:54:03 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-08 07:05:44 +04:00
|
|
|
static int
|
|
|
|
ddp_rcvd(struct socket *so, int flags, struct lwp *l)
|
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2014-07-23 17:17:18 +04:00
|
|
|
static int
|
|
|
|
ddp_recvoob(struct socket *so, struct mbuf *m, int flags)
|
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2014-08-05 11:55:31 +04:00
|
|
|
static int
|
2015-05-02 20:18:03 +03:00
|
|
|
ddp_send(struct socket *so, struct mbuf *m, struct sockaddr *nam,
|
2014-08-05 11:55:31 +04:00
|
|
|
struct mbuf *control, struct lwp *l)
|
|
|
|
{
|
|
|
|
struct ddpcb *ddp = sotoddpcb(so);
|
|
|
|
int error = 0;
|
2014-08-07 11:51:28 +04:00
|
|
|
int s = 0; /* XXX gcc 4.8 warns on sgimips */
|
2014-08-05 11:55:31 +04:00
|
|
|
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
KASSERT(ddp != NULL);
|
|
|
|
|
|
|
|
if (nam) {
|
|
|
|
if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT)
|
|
|
|
return EISCONN;
|
|
|
|
s = splnet();
|
2015-05-02 20:18:03 +03:00
|
|
|
error = at_pcbconnect(ddp, (struct sockaddr_at *)nam);
|
2014-08-05 11:55:31 +04:00
|
|
|
if (error) {
|
|
|
|
splx(s);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ddp->ddp_fsat.sat_port == ATADDR_ANYPORT)
|
|
|
|
return ENOTCONN;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = ddp_output(m, ddp);
|
|
|
|
m = NULL;
|
|
|
|
if (nam) {
|
|
|
|
at_pcbdisconnect(ddp);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2014-07-23 17:17:18 +04:00
|
|
|
static int
|
|
|
|
ddp_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
|
|
|
|
{
|
|
|
|
KASSERT(solocked(so));
|
|
|
|
|
2019-01-28 15:53:01 +03:00
|
|
|
m_freem(m);
|
|
|
|
m_freem(control);
|
2014-07-23 17:17:18 +04:00
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2014-08-09 09:33:00 +04:00
|
|
|
static int
|
|
|
|
ddp_purgeif(struct socket *so, struct ifnet *ifp)
|
|
|
|
{
|
|
|
|
|
|
|
|
mutex_enter(softnet_lock);
|
|
|
|
at_purgeif(ifp);
|
|
|
|
mutex_exit(softnet_lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
/*
|
|
|
|
* For the moment, this just find the pcb with the correct local address.
|
|
|
|
* In the future, this will actually do some real searching, so we can use
|
|
|
|
* the sender's address to do de-multiplexing on a single port to many
|
|
|
|
* sockets (pcbs).
|
|
|
|
*/
|
|
|
|
struct ddpcb *
|
2006-10-12 05:30:41 +04:00
|
|
|
ddp_search(
|
2006-11-16 04:32:37 +03:00
|
|
|
struct sockaddr_at *from,
|
2006-10-12 05:30:41 +04:00
|
|
|
struct sockaddr_at *to,
|
|
|
|
struct at_ifaddr *aa)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
|
|
|
struct ddpcb *ddp;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for bad ports.
|
|
|
|
*/
|
Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.
The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing. Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.
Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously. Of course, all design oversights and bugs are
mine.
DETAILS
1 I added to each address family a pool of sockaddrs. I have
introduced routines for allocating, copying, and duplicating,
and freeing sockaddrs:
struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
struct sockaddr *sockaddr_copy(struct sockaddr *dst,
const struct sockaddr *src);
struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
void sockaddr_free(struct sockaddr *sa);
sockaddr_alloc() returns either a sockaddr from the pool belonging
to the specified family, or NULL if the pool is exhausted. The
returned sockaddr has the right size for that family; sa_family
and sa_len fields are initialized to the family and sockaddr
length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
sockaddr_in). sockaddr_free() puts the given sockaddr back into
its family's pool.
sockaddr_dup() and sockaddr_copy() work analogously to strdup()
and strcpy(), respectively. sockaddr_copy() KASSERTs that the
family of the destination and source sockaddrs are alike.
The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
passed directly to pool_get(9).
2 I added routines for initializing sockaddrs in each address
family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
etc. They are fairly self-explanatory.
3 structs route_in6 and route_iso are no more. All protocol families
use struct route. I have changed the route cache, 'struct route',
so that it does not contain storage space for a sockaddr. Instead,
struct route points to a sockaddr coming from the pool the sockaddr
belongs to. I added a new method to struct route, rtcache_setdst(),
for setting the cache destination:
int rtcache_setdst(struct route *, const struct sockaddr *);
rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
available to create the sockaddr storage.
It is now possible for rtcache_getdst() to return NULL if, say,
rtcache_setdst() failed. I check the return value for NULL
everywhere in the kernel.
4 Each routing domain (struct domain) has a list of live route
caches, dom_rtcache. rtflushall(sa_family_t af) looks up the
domain indicated by 'af', walks the domain's list of route caches
and invalidates each one.
2007-05-03 00:40:22 +04:00
|
|
|
if (to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST)
|
|
|
|
return NULL;
|
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
/*
|
|
|
|
* Make sure the local address matches the sent address. What about
|
|
|
|
* the interface?
|
|
|
|
*/
|
|
|
|
for (ddp = ddp_ports[to->sat_port - 1]; ddp; ddp = ddp->ddp_pnext) {
|
|
|
|
/* XXX should we handle 0.YY? */
|
|
|
|
|
|
|
|
/* XXXX.YY to socket on destination interface */
|
|
|
|
if (to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net &&
|
|
|
|
to->sat_addr.s_node == ddp->ddp_lsat.sat_addr.s_node) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* 0.255 to socket on receiving interface */
|
|
|
|
if (to->sat_addr.s_node == ATADDR_BCAST &&
|
|
|
|
(to->sat_addr.s_net == 0 ||
|
|
|
|
to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net) &&
|
|
|
|
ddp->ddp_lsat.sat_addr.s_net == AA_SAT(aa)->sat_addr.s_net) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* XXXX.0 to socket on destination interface */
|
|
|
|
if (to->sat_addr.s_net == aa->aa_firstnet &&
|
|
|
|
to->sat_addr.s_node == 0 &&
|
|
|
|
ntohs(ddp->ddp_lsat.sat_addr.s_net) >=
|
|
|
|
ntohs(aa->aa_firstnet) &&
|
|
|
|
ntohs(ddp->ddp_lsat.sat_addr.s_net) <=
|
|
|
|
ntohs(aa->aa_lastnet)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (ddp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize all the ddp & appletalk stuff
|
|
|
|
*/
|
|
|
|
void
|
2008-04-23 19:17:42 +04:00
|
|
|
ddp_init(void)
|
1997-04-03 01:31:01 +04:00
|
|
|
{
|
2008-04-23 19:17:42 +04:00
|
|
|
|
|
|
|
ddpstat_percpu = percpu_alloc(sizeof(uint64_t) * DDP_NSTATS);
|
|
|
|
|
1997-04-03 01:31:01 +04:00
|
|
|
TAILQ_INIT(&at_ifaddr);
|
|
|
|
atintrq1.ifq_maxlen = IFQ_MAXLEN;
|
|
|
|
atintrq2.ifq_maxlen = IFQ_MAXLEN;
|
2016-10-03 14:06:06 +03:00
|
|
|
IFQ_LOCK_INIT(&atintrq1);
|
|
|
|
IFQ_LOCK_INIT(&atintrq2);
|
2003-02-26 10:53:04 +03:00
|
|
|
|
|
|
|
MOWNER_ATTACH(&atalk_tx_mowner);
|
|
|
|
MOWNER_ATTACH(&atalk_rx_mowner);
|
2011-05-08 17:51:31 +04:00
|
|
|
MOWNER_ATTACH(&aarp_mowner);
|
1997-04-03 01:31:01 +04:00
|
|
|
}
|
|
|
|
|
2014-05-20 23:04:00 +04:00
|
|
|
PR_WRAP_USRREQS(ddp)
|
|
|
|
#define ddp_attach ddp_attach_wrapper
|
|
|
|
#define ddp_detach ddp_detach_wrapper
|
2014-07-09 18:41:42 +04:00
|
|
|
#define ddp_accept ddp_accept_wrapper
|
2014-07-24 19:12:03 +04:00
|
|
|
#define ddp_bind ddp_bind_wrapper
|
|
|
|
#define ddp_listen ddp_listen_wrapper
|
2014-07-30 14:04:25 +04:00
|
|
|
#define ddp_connect ddp_connect_wrapper
|
2014-08-09 09:33:00 +04:00
|
|
|
#define ddp_connect2 ddp_connect2_wrapper
|
split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions
xxx_disconnect(struct socket *)
xxx_shutdown(struct socket *)
xxx_abort(struct socket *)
- always KASSERT(solocked(so)) even if not implemented
- replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
with calls to pr_{disconnect,shutdown,abort}() respectively
rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().
- {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
- {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
- unp_shutdown() -> unp_shutdown1()
patch reviewed by rmind
2014-07-31 07:39:35 +04:00
|
|
|
#define ddp_disconnect ddp_disconnect_wrapper
|
|
|
|
#define ddp_shutdown ddp_shutdown_wrapper
|
|
|
|
#define ddp_abort ddp_abort_wrapper
|
2014-06-22 12:10:18 +04:00
|
|
|
#define ddp_ioctl ddp_ioctl_wrapper
|
2014-07-06 07:33:33 +04:00
|
|
|
#define ddp_stat ddp_stat_wrapper
|
* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).
- KASSERT(solocked(so)) always in new functions even if request
is not implemented
- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.
* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()
- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.
* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).
- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()
* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).
- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()
note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.
patch reviewed by rmind
welcome to 6.99.47
2014-07-09 08:54:03 +04:00
|
|
|
#define ddp_peeraddr ddp_peeraddr_wrapper
|
|
|
|
#define ddp_sockaddr ddp_sockaddr_wrapper
|
2014-08-08 07:05:44 +04:00
|
|
|
#define ddp_rcvd ddp_rcvd_wrapper
|
2014-07-23 17:17:18 +04:00
|
|
|
#define ddp_recvoob ddp_recvoob_wrapper
|
2014-08-05 11:55:31 +04:00
|
|
|
#define ddp_send ddp_send_wrapper
|
2014-07-23 17:17:18 +04:00
|
|
|
#define ddp_sendoob ddp_sendoob_wrapper
|
2014-08-09 09:33:00 +04:00
|
|
|
#define ddp_purgeif ddp_purgeif_wrapper
|
2014-05-18 18:46:15 +04:00
|
|
|
|
|
|
|
const struct pr_usrreqs ddp_usrreqs = {
|
2014-05-19 06:51:24 +04:00
|
|
|
.pr_attach = ddp_attach,
|
|
|
|
.pr_detach = ddp_detach,
|
2014-07-09 18:41:42 +04:00
|
|
|
.pr_accept = ddp_accept,
|
2014-07-24 19:12:03 +04:00
|
|
|
.pr_bind = ddp_bind,
|
|
|
|
.pr_listen = ddp_listen,
|
2014-07-30 14:04:25 +04:00
|
|
|
.pr_connect = ddp_connect,
|
2014-08-09 09:33:00 +04:00
|
|
|
.pr_connect2 = ddp_connect2,
|
split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions
xxx_disconnect(struct socket *)
xxx_shutdown(struct socket *)
xxx_abort(struct socket *)
- always KASSERT(solocked(so)) even if not implemented
- replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
with calls to pr_{disconnect,shutdown,abort}() respectively
rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().
- {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
- {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
- unp_shutdown() -> unp_shutdown1()
patch reviewed by rmind
2014-07-31 07:39:35 +04:00
|
|
|
.pr_disconnect = ddp_disconnect,
|
|
|
|
.pr_shutdown = ddp_shutdown,
|
|
|
|
.pr_abort = ddp_abort,
|
2014-06-22 12:10:18 +04:00
|
|
|
.pr_ioctl = ddp_ioctl,
|
2014-07-06 07:33:33 +04:00
|
|
|
.pr_stat = ddp_stat,
|
* split PRU_PEERADDR and PRU_SOCKADDR function out of pr_generic()
usrreq switches and put into separate functions
xxx_{peer,sock}addr(struct socket *, struct mbuf *).
- KASSERT(solocked(so)) always in new functions even if request
is not implemented
- KASSERT(pcb != NULL) and KASSERT(nam) if the request is
implemented and not for tcp.
* for tcp roll #ifdef KPROF and #ifdef DEBUG code from tcp_usrreq() into
easier to cut & paste functions tcp_debug_capture() and
tcp_debug_trace()
- functions provided by rmind
- remaining use of PRU_{PEER,SOCK}ADDR #define to be removed in a
future commit.
* rename netbt functions to permit consistency of pru function names
(as has been done with other requests already split out).
- l2cap_{peer,sock}addr() -> l2cap_{peer,sock}_addr_pcb()
- rfcomm_{peer,sock}addr() -> rfcomm_{peer,sock}_addr_pcb()
- sco_{peer,sock}addr() -> sco_{peer,sock}_addr_pcb()
* split/refactor do_sys_getsockname(lwp, fd, which, nam) into
two functions do_sys_get{peer,sock}name(fd, nam).
- move PRU_PEERADDR handling into do_sys_getpeername() from
do_sys_getsockname()
- have svr4_stream directly call do_sys_get{sock,peer}name()
respectively instead of providing `which' & fix a DPRINTF string
that incorrectly wrote "getpeername" when it meant "getsockname"
- fix sys_getpeername() and sys_getsockname() to call
do_sys_get{sock,peer}name() without `which' and `lwp' & adjust
comments
- bump kernel version for removal of lwp & which parameters from
do_sys_getsockname()
note: future cleanup to remove struct mbuf * abuse in
xxx_{peer,sock}name()
still to come, not done in this commit since it is easier to do post
split.
patch reviewed by rmind
welcome to 6.99.47
2014-07-09 08:54:03 +04:00
|
|
|
.pr_peeraddr = ddp_peeraddr,
|
|
|
|
.pr_sockaddr = ddp_sockaddr,
|
2014-08-08 07:05:44 +04:00
|
|
|
.pr_rcvd = ddp_rcvd,
|
2014-07-23 17:17:18 +04:00
|
|
|
.pr_recvoob = ddp_recvoob,
|
2014-08-05 11:55:31 +04:00
|
|
|
.pr_send = ddp_send,
|
2014-07-23 17:17:18 +04:00
|
|
|
.pr_sendoob = ddp_sendoob,
|
2014-08-09 09:33:00 +04:00
|
|
|
.pr_purgeif = ddp_purgeif,
|
2014-05-18 18:46:15 +04:00
|
|
|
};
|
2008-04-23 19:17:42 +04:00
|
|
|
|
|
|
|
static int
|
|
|
|
sysctl_net_atalk_ddp_stats(SYSCTLFN_ARGS)
|
|
|
|
{
|
|
|
|
|
2008-05-04 11:22:14 +04:00
|
|
|
return (NETSTAT_SYSCTL(ddpstat_percpu, DDP_NSTATS));
|
2008-04-23 19:17:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sysctl for DDP variables.
|
|
|
|
*/
|
|
|
|
SYSCTL_SETUP(sysctl_net_atalk_ddp_setup, "sysctl net.atalk.ddp subtree setup")
|
|
|
|
{
|
|
|
|
|
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_NODE, "atalk", NULL,
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_APPLETALK, CTL_EOL);
|
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_NODE, "ddp",
|
|
|
|
SYSCTL_DESCR("DDP related settings"),
|
|
|
|
NULL, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_APPLETALK, ATPROTO_DDP, CTL_EOL);
|
|
|
|
|
|
|
|
sysctl_createv(clog, 0, NULL, NULL,
|
|
|
|
CTLFLAG_PERMANENT,
|
|
|
|
CTLTYPE_STRUCT, "stats",
|
|
|
|
SYSCTL_DESCR("DDP statistics"),
|
|
|
|
sysctl_net_atalk_ddp_stats, 0, NULL, 0,
|
|
|
|
CTL_NET, PF_APPLETALK, ATPROTO_DDP, CTL_CREATE,
|
|
|
|
CTL_EOL);
|
|
|
|
}
|