Home | History | Annotate | Download | only in netatalk
History log of /src/sys/netatalk/aarp.c
RevisionDateAuthorComments
 1.47  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.46  31-Jul-2023  dholland branches: 1.46.6;
aarp.c: one more thing -- both macro params should get parens
 1.45  31-Jul-2023  dholland aarp.c: whitespace
 1.44  31-Jul-2023  dholland aarp.c: fix wrong indent and add missing braces inside macro
 1.43  22-Dec-2018  maxv Replace M_ALIGN and MH_ALIGN by m_align.
 1.42  29-May-2018  maxv branches: 1.42.2;
Remove aarp_clean, unused. By the way this function was probably buggy
since it didn't reset aat_hold to NULL.
 1.41  17-Feb-2018  rjs branches: 1.41.2;
Add NETATALKDEBUG to the option header and include that in the main source
files.
 1.40  09-Dec-2017  maxv Mmh, pull up the packet to ether_aarp, otherwise we're reading past the
end of the mbuf.
 1.39  01-Aug-2016  ozaki-r branches: 1.39.8;
Apply pserialize and psref to struct ifaddr and its variants

This change makes struct ifaddr and its variants (in_ifaddr and in6_ifaddr)
MP-safe by using pserialize and psref. At this moment, pserialize_perform
and psref_target_destroy are disabled because (1) we don't need them
because of softnet_lock (2) they cause a deadlock because of softnet_lock.
So we'll enable them when we remove softnet_lock in the future.
 1.38  07-Jul-2016  ozaki-r branches: 1.38.2;
Switch the address list of intefaces to pslist(9)

As usual, we leave the old list to avoid breaking kvm(3) users.
 1.37  20-Jun-2016  knakahara apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).
 1.36  31-Jan-2012  hauke branches: 1.36.6; 1.36.24;
Fix AppleTalk name registration, as discussed on the port-macppc list
<http://mail-index.netbsd.org/port-macppc/2010/07/09/msg001119.html>
and in PR kern/44412, by looping back ddp broadcasts.

Patch submitted by David Riley against netbsd-5, adaptation for
-current and minor KNF touchup by me.

Needs to be pulled up to netbsd-5.
 1.35  08-May-2011  bouyer branches: 1.35.4; 1.35.8;
aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Should fix PR kern/44734
 1.34  12-Sep-2009  tsutsui branches: 1.34.4; 1.34.6;
Make sure to set length in AARP-response packets. PR kern/41124
 1.33  18-Apr-2009  tsutsui Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
 1.32  18-Mar-2009  cegger bcopy -> memcpy
 1.31  18-Mar-2009  cegger bzero -> memset
 1.30  18-Mar-2009  cegger bcmp -> memcmp
 1.29  15-Mar-2009  cegger ansify function definitions
 1.28  14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.27  24-Apr-2008  ad branches: 1.27.2; 1.27.10; 1.27.12; 1.27.16;
Merge the socket locking patch:

- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
 1.26  04-Dec-2007  dyoung branches: 1.26.12; 1.26.14;
Use IFADDR_FOREACH().
 1.25  26-Aug-2007  dyoung branches: 1.25.2; 1.25.8; 1.25.10;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).

Use sockaddr_dl_setaddr() in a few places.
 1.24  09-Jul-2007  ad branches: 1.24.2; 1.24.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.23  02-May-2007  dyoung 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.
 1.22  17-Feb-2007  dyoung branches: 1.22.4; 1.22.6;
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.
 1.21  16-Nov-2006  christos branches: 1.21.4;
__unused removal on arguments; approved by core.
 1.20  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.19  10-Oct-2006  dogcow change the MOWNER_INIT define to take two args; fix extant struct mowner
decls to use it. Makes options MBUFTRACE compile again and not whinge about
missing structure declarations. (Also makes initialization consistent.)
 1.18  11-Dec-2005  christos branches: 1.18.20; 1.18.22;
merge ktrace-lwp.
 1.17  24-Aug-2005  christos PR/31051: Kousaku Nakahara: can't find the device from Macintosh through
AppleTalk(Netatalk) in the network including a seed router
Byte order problem, fixed as suggested.
 1.16  29-May-2005  christos branches: 1.16.2;
sprinkle const.
 1.15  08-Jan-2005  yamt branches: 1.15.8;
netatalk: remove a redundant extern decl of etherbroadcastaddr.
 1.14  23-Jun-2003  martin branches: 1.14.2;
Make sure to include opt_foo.h if a defflag option FOO is used.
 1.13  27-May-2003  itojun - don't use M_WAIT within splnet.
- retain m_pkthdr for mbuf passed down to ifp->if_output.
pointed out by is@netbsd
 1.12  26-Feb-2003  matt Update for MBUFTRACE.
 1.11  28-Jan-2003  wiz allocate, not alocate. Noted by mjl, not mjll.
 1.10  21-Dec-2002  kristerw aarptab_size is never used. Remove.
 1.9  22-Oct-2002  perry ARGSUSED
 1.8  15-Nov-2001  lukem branches: 1.8.10;
don't need <sys/types.h> when including <sys/param.h>
 1.7  13-Nov-2001  lukem add RCSIDs
 1.6  13-Apr-2001  thorpej branches: 1.6.2;
Remove the use of splimp() from the NetBSD kernel. splnet()
and only splnet() is allowed for the protection of data structures
used by network devices.
 1.5  23-Mar-2000  thorpej branches: 1.5.6;
New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.4  21-Sep-1999  matt branches: 1.4.2;
Make NETATALK over FDDI.
 1.3  13-Oct-1998  kim branches: 1.3.4;
Use ETHERTYPE_ATALK instead of ETHERTYPE_AT. The former seems more common.
Our other constants also use "ATALK".

Added many new ETHERTYPE constants to sys/net/ethertypes.h, including the
ones from libpcap and tcpdump "ethertype.h" files.
 1.2  03-Apr-1997  christos Make at_ifawithnet take an ifnet arg instead of an ifaddr. Suggested by
Ignatios.
 1.1  02-Apr-1997  christos Appletalk networking stack. Code based on netatalk release beta-970220
from toccata.fugue.com. Ported to netbsd by Bill Studenmund.
Changes:
- KNF
- remove endian.h
- adapt to the new arp code.
- fix small biff's with spl/splx.
 1.3.4.1  11-Dec-1998  kenh The beginnings of interface detach support. Still some bugs, but mostly
works for me.

This work was originally by Bill Studenmund, and cleaned up by me.
 1.4.2.2  21-Apr-2001  bouyer Sync with HEAD
 1.4.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.6.5  29-Dec-2002  thorpej Sync with HEAD.
 1.5.6.4  11-Nov-2002  nathanw Catch up to -current
 1.5.6.3  08-Jan-2002  nathanw Catch up to -current.
 1.5.6.2  14-Nov-2001  nathanw Catch up to -current.
 1.5.6.1  21-Jun-2001  nathanw Catch up to -current.
 1.6.2.1  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.8.10.2  26-Oct-2005  riz Pull up following revision(s) (requested by taca in ticket #5851):
sys/netatalk/aarp.c: revision 1.17
PR/31051: Kousaku Nakahara: can't find the device from Macintosh through
AppleTalk(Netatalk) in the network including a seed router
Byte order problem, fixed as suggested.
 1.8.10.1  19-Jun-2003  grant Pull up revision 1.13 (requested by itojun in ticket #1316):

- don't use M_WAIT within splnet.
- retain m_pkthdr for mbuf passed down to ifp->if_output.
pointed out by is@netbsd
 1.14.2.2  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.14.2.1  17-Jan-2005  skrll Sync with HEAD.
 1.15.8.1  09-May-2006  tron Pull up following revision(s) (requested by hira in ticket #1310):
sys/netatalk/aarp.c: revision 1.17
PR/31051: Kousaku Nakahara: can't find the device from Macintosh through
AppleTalk(Netatalk) in the network including a seed router
Byte order problem, fixed as suggested.
 1.16.2.5  07-Dec-2007  yamt sync with head
 1.16.2.4  03-Sep-2007  yamt sync with head.
 1.16.2.3  26-Feb-2007  yamt sync with head.
 1.16.2.2  30-Dec-2006  yamt sync with head.
 1.16.2.1  21-Jun-2006  yamt sync with head.
 1.18.22.2  10-Dec-2006  yamt sync with head.
 1.18.22.1  22-Oct-2006  yamt sync with head
 1.18.20.1  18-Nov-2006  ad Sync with head.
 1.21.4.2  07-May-2007  yamt sync with head.
 1.21.4.1  27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.22.6.1  11-Jul-2007  mjf Sync with head.
 1.22.4.3  09-Oct-2007  ad Sync with head.
 1.22.4.2  01-Jul-2007  ad Adapt to callout API change.
 1.22.4.1  08-Jun-2007  ad Sync with head.
 1.24.6.2  09-Dec-2007  jmcneill Sync with HEAD.
 1.24.6.1  03-Sep-2007  jmcneill Sync with HEAD.
 1.24.2.1  03-Sep-2007  skrll Sync with HEAD.
 1.25.10.1  08-Dec-2007  ad Sync with head.
 1.25.8.1  08-Dec-2007  mjf Sync with HEAD.
 1.25.2.1  09-Jan-2008  matt sync with HEAD
 1.26.14.1  18-May-2008  yamt sync with head.
 1.26.12.1  02-Jun-2008  mjf Sync with HEAD.
 1.27.16.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.27.12.2  21-Apr-2012  riz Pull up following revision(s) (requested by hauke in ticket #1749):
sys/netatalk/aarp.c: revision 1.36
sys/netatalk/ddp_output.c: revision 1.16
Fix AppleTalk name registration, as discussed on the port-macppc list
<http://mail-index.netbsd.org/port-macppc/2010/07/09/msg001119.html>
and in PR kern/44412, by looping back ddp broadcasts.
Patch submitted by David Riley against netbsd-5, adaptation for
-current and minor KNF touchup by me.
Needs to be pulled up to netbsd-5.
 1.27.12.1  30-Jun-2011  sborrill Pull up the following revisions(s) (requested by bouyer in ticket #1622):
sys/netatalk/aarp.c: revision 1.35
sys/netatalk/aarp.h: revision 1.3
sys/netatalk/ddp_usrreq.c: revision 1.40

aarpprobe() is called before MOWNER_ATTACH(&aarp_mowner), leading
to a DIAGNOSTIC panic when MBUFTRACE is defined and atalkd is started.
Fix by moving MOWNER_ATTACH(&aarp_mowner) to ddp_init().
Fixes PR kern/44734
 1.27.10.1  28-Apr-2009  skrll Sync with HEAD.
 1.27.2.2  16-Sep-2009  yamt sync with head
 1.27.2.1  04-May-2009  yamt sync with head.
 1.34.6.1  06-Jun-2011  jruoho Sync with HEAD.
 1.34.4.1  31-May-2011  rmind sync with head
 1.35.8.1  18-Feb-2012  mrg merge to -current.
 1.35.4.1  17-Apr-2012  yamt sync with head
 1.36.24.2  05-Oct-2016  skrll Sync with HEAD
 1.36.24.1  09-Jul-2016  skrll Sync with HEAD
 1.36.6.1  03-Dec-2017  jdolecek update from HEAD
 1.38.2.1  06-Aug-2016  pgoyette Sync with HEAD
 1.39.8.1  09-Jan-2018  snj Pull up following revision(s) (requested by maxv in ticket #479):
sys/netatalk/aarp.c: revision 1.40
Mmh, pull up the packet to ether_aarp, otherwise we're reading past the
end of the mbuf.
 1.41.2.2  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.41.2.1  25-Jun-2018  pgoyette Sync with HEAD
 1.42.2.1  10-Jun-2019  christos Sync with HEAD
 1.46.6.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed