diff options
author | melifaro <melifaro@FreeBSD.org> | 2014-01-18 23:24:51 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2014-01-18 23:24:51 +0000 |
commit | 881c9e28bfecd7527db2dc2584a7ab19e733c821 (patch) | |
tree | 27eae7c12b15b514ef9982e2268330a4e599db09 /sys/net/if_fddisubr.c | |
parent | 978dfbc51760372d61ca97fcdc575a28649eba4d (diff) | |
download | FreeBSD-src-881c9e28bfecd7527db2dc2584a7ab19e733c821.zip FreeBSD-src-881c9e28bfecd7527db2dc2584a7ab19e733c821.tar.gz |
Simplify filling sockaddr_dl structure for if_resolvemulti()
callback providers. link_init_sdl() function can be used to
fill most of the parameters. Use caller stack instead of
allocation / freing memory for each request. Do not drop support
for extra-long (probably non-existing) link-layer protocols by
introducing link_alloc_sdl() (used by if_resolvemulti() callback)
and link_free_sdl() (used by caller).
Since this change breaks KBI, MFC requires slightly different approach
(link_init_sdl() auto-allocating buffer if necessary to handle cases
with unmodified if_resolvemulti() callers).
MFC after: 2 weeks
Diffstat (limited to 'sys/net/if_fddisubr.c')
-rw-r--r-- | sys/net/if_fddisubr.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 2f03bb7..2bb818b 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -729,14 +729,7 @@ fddi_resolvemulti(ifp, llsa, sa) sin = (struct sockaddr_in *)sa; if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) return (EADDRNOTAVAIL); - sdl = malloc(sizeof *sdl, M_IFMADDR, - M_NOWAIT | M_ZERO); - if (sdl == NULL) - return (ENOMEM); - sdl->sdl_len = sizeof *sdl; - sdl->sdl_family = AF_LINK; - sdl->sdl_index = ifp->if_index; - sdl->sdl_type = IFT_FDDI; + sdl = link_init_sdl(ifp, *llsa, IFT_FDDI); sdl->sdl_nlen = 0; sdl->sdl_alen = FDDI_ADDR_LEN; sdl->sdl_slen = 0; @@ -760,14 +753,7 @@ fddi_resolvemulti(ifp, llsa, sa) } if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) return (EADDRNOTAVAIL); - sdl = malloc(sizeof *sdl, M_IFMADDR, - M_NOWAIT | M_ZERO); - if (sdl == NULL) - return (ENOMEM); - sdl->sdl_len = sizeof *sdl; - sdl->sdl_family = AF_LINK; - sdl->sdl_index = ifp->if_index; - sdl->sdl_type = IFT_FDDI; + sdl = link_init_sdl(ifp, *llsa, IFT_FDDI); sdl->sdl_nlen = 0; sdl->sdl_alen = FDDI_ADDR_LEN; sdl->sdl_slen = 0; |