Date: Sat, 3 Jan 2015 19:09:07 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r276631 - in projects/routing/sys: net netinet netinet6 Message-ID: <201501031909.t03J973q012470@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Sat Jan 3 19:09:06 2015 New Revision: 276631 URL: https://svnweb.freebsd.org/changeset/base/276631 Log: * Use unified code for deleting entry by sockaddr instead of per-af one. * Remove now unused llt_delete_addr callback. Modified: projects/routing/sys/net/if_llatbl.c projects/routing/sys/net/if_llatbl_var.h projects/routing/sys/netinet/in.c projects/routing/sys/netinet6/in6.c Modified: projects/routing/sys/net/if_llatbl.c ============================================================================== --- projects/routing/sys/net/if_llatbl.c Sat Jan 3 18:38:46 2015 (r276630) +++ projects/routing/sys/net/if_llatbl.c Sat Jan 3 19:09:06 2015 (r276631) @@ -445,14 +445,6 @@ lltable_create_lle(struct lltable *llt, return (llt->llt_create(llt, flags, paddr)); } -int -lltable_delete_addr(struct lltable *llt, u_int flags, - const struct sockaddr *l3addr) -{ - - return llt->llt_delete_addr(llt, flags, l3addr); -} - void lltable_link_entry(struct lltable *llt, struct llentry *lle) { @@ -581,8 +573,34 @@ lla_rt_output(struct rt_msghdr *rtm, str break; case RTM_DELETE: - error = lltable_delete_addr(llt, 0, dst); - return (error == 0 ? 0 : ENOENT); + l3addr = llt->llt_get_sa_addr(dst); + + IF_AFDATA_CFG_WLOCK(ifp); + lle = lltable_lookup_lle(llt, LLE_UNLOCKED, l3addr); + + if (lle == NULL) { + IF_AFDATA_CFG_WUNLOCK(ifp); + return (ENOENT); + } + + /* Skipping LLE_IFADDR record */ + if ((lle->la_flags & LLE_IFADDR) != 0) { + IF_AFDATA_CFG_WUNLOCK(ifp); + return (0); + } + + LLE_WLOCK(lle); + IF_AFDATA_RUN_WLOCK(ifp); + lltable_unlink_entry(llt, lle); + IF_AFDATA_RUN_WUNLOCK(ifp); + IF_AFDATA_CFG_WUNLOCK(ifp); + +#ifdef DIAGNOSTIC + log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); +#endif + EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_DELETED); + llt->llt_clear_entry(llt, lle); + break; default: error = EINVAL; Modified: projects/routing/sys/net/if_llatbl_var.h ============================================================================== --- projects/routing/sys/net/if_llatbl_var.h Sat Jan 3 18:38:46 2015 (r276630) +++ projects/routing/sys/net/if_llatbl_var.h Sat Jan 3 19:09:06 2015 (r276631) @@ -50,8 +50,6 @@ typedef struct llentry *(llt_lookup_t)(s const void *paddr); typedef struct llentry *(llt_create_t)(struct lltable *, u_int flags, const void *paddr); -typedef int (llt_delete_addr_t)(struct lltable *, u_int flags, - const struct sockaddr *l3addr); typedef int (llt_dump_entry_t)(struct lltable *, struct llentry *, struct sysctl_req *); typedef uint32_t (llt_hash_t)(const struct llentry *); @@ -78,7 +76,6 @@ struct lltable { llt_lookup_t *llt_lookup; llt_create_t *llt_create; - llt_delete_addr_t *llt_delete_addr; llt_dump_entry_t *llt_dump_entry; llt_hash_t *llt_hash; llt_match_prefix_t *llt_match_prefix; @@ -114,8 +111,6 @@ lltable_lookup_lle(struct lltable *llt, struct llentry *lltable_create_lle(struct lltable *llt, u_int flags, const void *paddr); -int lltable_delete_addr(struct lltable *llt, u_int flags, - const struct sockaddr *l3addr); void lltable_link_entry(struct lltable *llt, struct llentry *lle); void lltable_unlink_entry(struct lltable *llt, struct llentry *lle); Modified: projects/routing/sys/netinet/in.c ============================================================================== --- projects/routing/sys/netinet/in.c Sat Jan 3 18:38:46 2015 (r276630) +++ projects/routing/sys/netinet/in.c Sat Jan 3 19:09:06 2015 (r276631) @@ -1138,50 +1138,6 @@ in_lltable_find_dst(struct lltable *llt, return (lle); } -static int -in_lltable_delete(struct lltable *llt, u_int flags, - const struct sockaddr *l3addr) -{ - const struct sockaddr_in *sin = (const struct sockaddr_in *)l3addr; - struct ifnet *ifp = llt->llt_ifp; - struct llentry *lle; - - IF_AFDATA_CFG_UNLOCK_ASSERT(ifp); - KASSERT(l3addr->sa_family == AF_INET, - ("sin_family %d", l3addr->sa_family)); - - IF_AFDATA_CFG_WLOCK(ifp); - lle = in_lltable_find_dst(llt, sin->sin_addr); - if (lle == NULL) { - IF_AFDATA_CFG_WUNLOCK(ifp); -#ifdef DIAGNOSTIC - log(LOG_INFO, "interface address is missing from cache = %p\n", - lle); -#endif - return (ENOENT); - } - - /* Skipping LLE_IFADDR record */ - if ((lle->la_flags & LLE_IFADDR) != 0 && (flags & LLE_IFADDR) == 0) { - IF_AFDATA_CFG_WUNLOCK(ifp); - return (0); - } - - LLE_WLOCK(lle); - IF_AFDATA_RUN_WLOCK(ifp); - lltable_unlink_entry(llt, lle); - IF_AFDATA_RUN_WUNLOCK(ifp); - IF_AFDATA_CFG_WUNLOCK(ifp); - - EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_DELETED); -#ifdef DIAGNOSTIC - log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); -#endif - llt->llt_clear_entry(llt, lle); - - return (0); -} - static struct llentry * in_lltable_create(struct lltable *llt, u_int flags, const void *paddr) { @@ -1315,7 +1271,6 @@ in_domifattach(struct ifnet *ifp) llt->llt_lookup = in_lltable_lookup; llt->llt_create = in_lltable_create; - llt->llt_delete_addr = in_lltable_delete; llt->llt_dump_entry = in_lltable_dump_entry; llt->llt_hash = in_lltable_hash; llt->llt_get_sa_addr = in_lltable_get_sa_addr; Modified: projects/routing/sys/netinet6/in6.c ============================================================================== --- projects/routing/sys/netinet6/in6.c Sat Jan 3 18:38:46 2015 (r276630) +++ projects/routing/sys/netinet6/in6.c Sat Jan 3 19:09:06 2015 (r276631) @@ -2185,49 +2185,6 @@ in6_lltable_find_dst(struct lltable *llt return (lle); } -static int -in6_lltable_delete(struct lltable *llt, u_int flags, - const struct sockaddr *l3addr) -{ - const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)l3addr; - struct ifnet *ifp; - struct llentry *lle; - - ifp = llt->llt_ifp; - - IF_AFDATA_CFG_UNLOCK_ASSERT(ifp); - KASSERT(l3addr->sa_family == AF_INET6, - ("sin_family %d", l3addr->sa_family)); - - IF_AFDATA_CFG_WLOCK(ifp); - lle = in6_lltable_find_dst(llt, &sin6->sin6_addr); - - if (lle == NULL) { - IF_AFDATA_CFG_WUNLOCK(ifp); - return (ENOENT); - } - - /* Skipping LLE_IFADDR record */ - if ((lle->la_flags & LLE_IFADDR) != 0 && (flags & LLE_IFADDR) == 0) { - IF_AFDATA_CFG_WUNLOCK(ifp); - return (0); - } - - LLE_WLOCK(lle); - IF_AFDATA_RUN_WLOCK(ifp); - lltable_unlink_entry(llt, lle); - IF_AFDATA_RUN_WUNLOCK(ifp); - IF_AFDATA_CFG_WUNLOCK(ifp); - -#ifdef DIAGNOSTIC - log(LOG_INFO, "ifaddr cache = %p is deleted\n", lle); -#endif - EVENTHANDLER_INVOKE(lle_event, lle, LLENTRY_DELETED); - llt->llt_clear_entry(llt, lle); - - return (0); -} - static struct llentry * in6_lltable_create(struct lltable *llt, u_int flags, const void *paddr) @@ -2389,7 +2346,6 @@ in6_domifattach(struct ifnet *ifp) llt->llt_lookup = in6_lltable_lookup; llt->llt_create = in6_lltable_create; - llt->llt_delete_addr = in6_lltable_delete; llt->llt_dump_entry = in6_lltable_dump_entry; llt->llt_hash = in6_lltable_hash; llt->llt_get_sa_addr = in6_lltable_get_sa_addr;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501031909.t03J973q012470>