svn commit: r185955 - in projects/arpv2_merge_1/sys:
dev/cxgb/ulp/tom net
Kip Macy
kmacy at FreeBSD.org
Thu Dec 11 16:56:01 PST 2008
Author: kmacy
Date: Fri Dec 12 00:56:00 2008
New Revision: 185955
URL: http://svn.freebsd.org/changeset/base/185955
Log:
- remove cloning related fields from rtentry (genmask, parent, llinfo)
- move refcnt and flags together and convert both to int
Modified:
projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.c
projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.h
projects/arpv2_merge_1/sys/net/route.c
projects/arpv2_merge_1/sys/net/route.h
projects/arpv2_merge_1/sys/net/rtsock.c
Modified: projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.c
==============================================================================
--- projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.c Fri Dec 12 00:44:19 2008 (r185954)
+++ projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.c Fri Dec 12 00:56:00 2008 (r185955)
@@ -93,15 +93,15 @@ arp_hash(u32 key, int ifindex, const str
}
static inline void
-neigh_replace(struct l2t_entry *e, struct rtentry *rt)
+neigh_replace(struct l2t_entry *e, struct llentry *neigh)
{
- RT_LOCK(rt);
- RT_ADDREF(rt);
- RT_UNLOCK(rt);
+ LLE_WLOCK(neigh);
+ LLE_ADDREF(neigh);
+ LLE_WUNLOCK(neigh);
if (e->neigh)
- RTFREE(e->neigh);
- e->neigh = rt;
+ LLE_FREE(e->neigh);
+ e->neigh = neigh;
}
/*
@@ -164,9 +164,8 @@ arpq_enqueue(struct l2t_entry *e, struct
int
t3_l2t_send_slow(struct t3cdev *dev, struct mbuf *m, struct l2t_entry *e)
{
- struct rtentry *rt = e->neigh;
+ struct llentry *lle = e->neigh;
struct sockaddr_in sin;
- struct llentry *lle;
bzero(&sin, sizeof(struct sockaddr_in));
sin.sin_family = AF_INET;
@@ -223,7 +222,6 @@ again:
void
t3_l2t_send_event(struct t3cdev *dev, struct l2t_entry *e)
{
- struct rtentry *rt;
struct mbuf *m0;
struct sockaddr_in sin;
sin.sin_family = AF_INET;
@@ -323,18 +321,18 @@ found:
void
t3_l2e_free(struct l2t_data *d, struct l2t_entry *e)
{
- struct rtentry *rt = NULL;
-
+ struct llentry *lle;
+
mtx_lock(&e->lock);
if (atomic_load_acq_int(&e->refcnt) == 0) { /* hasn't been recycled */
- rt = e->neigh;
+ lle = e->neigh;
e->neigh = NULL;
}
mtx_unlock(&e->lock);
atomic_add_int(&d->nfree, 1);
- if (rt)
- RTFREE(rt);
+ if (lle)
+ LLE_FREE(lle);
}
@@ -343,11 +341,8 @@ t3_l2e_free(struct l2t_data *d, struct l
* Must be called with softirqs disabled.
*/
static inline void
-reuse_entry(struct l2t_entry *e, struct rtentry *neigh)
+reuse_entry(struct l2t_entry *e, struct llentry *neigh)
{
- struct llinfo_arp *la;
-
- la = (struct llinfo_arp *)neigh->rt_llinfo;
mtx_lock(&e->lock); /* avoid race with t3_l2t_free */
if (neigh != e->neigh)
@@ -364,13 +359,13 @@ reuse_entry(struct l2t_entry *e, struct
}
struct l2t_entry *
-t3_l2t_get(struct t3cdev *dev, struct rtentry *neigh, struct ifnet *ifp,
+t3_l2t_get(struct t3cdev *dev, struct llentry *neigh, struct ifnet *ifp,
struct sockaddr *sa)
{
struct l2t_entry *e;
struct l2t_data *d = L2DATA(dev);
u32 addr = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
- int ifidx = neigh->rt_ifp->if_index;
+ int ifidx = ifp->if_index;
int hash = arp_hash(addr, ifidx, d);
unsigned int smt_idx = ((struct port_info *)ifp->if_softc)->port_id;
@@ -450,20 +445,19 @@ handle_failed_resolution(struct t3cdev *
}
void
-t3_l2t_update(struct t3cdev *dev, struct rtentry *neigh,
+t3_l2t_update(struct t3cdev *dev, struct llentry *neigh,
uint8_t *enaddr, struct sockaddr *sa)
{
struct l2t_entry *e;
struct mbuf *arpq = NULL;
struct l2t_data *d = L2DATA(dev);
u32 addr = *(u32 *) &((struct sockaddr_in *)sa)->sin_addr;
- int ifidx = neigh->rt_ifp->if_index;
int hash = arp_hash(addr, ifidx, d);
struct llinfo_arp *la;
rw_rlock(&d->lock);
for (e = d->l2tab[hash].first; e; e = e->next)
- if (e->addr == addr && e->ifindex == ifidx) {
+ if (e->addr == addr) {
mtx_lock(&e->lock);
goto found;
}
Modified: projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.h
==============================================================================
--- projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.h Fri Dec 12 00:44:19 2008 (r185954)
+++ projects/arpv2_merge_1/sys/dev/cxgb/ulp/tom/cxgb_l2t.h Fri Dec 12 00:56:00 2008 (r185955)
@@ -68,7 +68,7 @@ struct l2t_entry {
int ifindex; /* neighbor's net_device's ifindex */
uint16_t smt_idx; /* SMT index */
uint16_t vlan; /* VLAN TCI (id: bits 0-11, prio: 13-15 */
- struct rtentry *neigh; /* associated neighbour */
+ struct llentry *neigh; /* associated neighbour */
struct l2t_entry *first; /* start of hash chain */
struct l2t_entry *next; /* next l2t_entry on chain */
struct mbuf *arpq_head; /* queue of packets awaiting resolution */
Modified: projects/arpv2_merge_1/sys/net/route.c
==============================================================================
--- projects/arpv2_merge_1/sys/net/route.c Fri Dec 12 00:44:19 2008 (r185954)
+++ projects/arpv2_merge_1/sys/net/route.c Fri Dec 12 00:56:00 2008 (r185955)
@@ -350,7 +350,7 @@ rtfree(struct rtentry *rt)
*/
RT_REMREF(rt);
if (rt->rt_refcnt > 0) {
- log(LOG_DEBUG, "%s: %p has %lu refs\t", __func__, rt, rt->rt_refcnt);
+ log(LOG_DEBUG, "%s: %p has %d refs\t", __func__, rt, rt->rt_refcnt);
goto done;
}
@@ -391,8 +391,6 @@ rtfree(struct rtentry *rt)
*/
if (rt->rt_ifa)
IFAFREE(rt->rt_ifa);
- rt->rt_parent = NULL; /* NB: no refcnt on parent */
-
/*
* The key is separatly alloc'd so free it (see rt_setgate()).
* This also frees the gateway, as they are always malloc'd
@@ -1045,27 +1043,6 @@ deldone:
/* XXX mtu manipulation will be done in rnh_addaddr -- itojun */
rn = rnh->rnh_addaddr(ndst, netmask, rnh, rt->rt_nodes);
- if (rn == NULL) {
- struct rtentry *rt2;
- /*
- * Uh-oh, we already have one of these in the tree.
- * We do a special hack: if the route that's already
- * there was generated by the cloning mechanism
- * then we just blow it away and retry the insertion
- * of the new one.
- */
- rt2 = rtalloc1_fib(dst, 0, RTF_RNH_LOCKED, fibnum);
- if (rt2 && rt2->rt_parent) {
- rtexpunge(rt2);
- RT_UNLOCK(rt2);
- rn = rnh->rnh_addaddr(ndst, netmask,
- rnh, rt->rt_nodes);
- } else if (rt2) {
- /* undo the extra ref we got */
- RTFREE_LOCKED(rt2);
- }
- }
-
/*
* If it still failed to go into the tree,
* then un-make it (this should be a function)
@@ -1081,7 +1058,6 @@ deldone:
senderr(EEXIST);
}
- rt->rt_parent = NULL;
/*
* If this protocol has something to add to this then
* allow it to do that as well.
Modified: projects/arpv2_merge_1/sys/net/route.h
==============================================================================
--- projects/arpv2_merge_1/sys/net/route.h Fri Dec 12 00:44:19 2008 (r185954)
+++ projects/arpv2_merge_1/sys/net/route.h Fri Dec 12 00:56:00 2008 (r185955)
@@ -135,15 +135,12 @@ struct rtentry {
#define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key)))
#define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask)))
struct sockaddr *rt_gateway; /* value */
- u_long rt_flags; /* up/down?, host/net */
+ int rt_flags; /* up/down?, host/net */
+ int rt_refcnt; /* # held references */
struct ifnet *rt_ifp; /* the answer: interface to use */
struct ifaddr *rt_ifa; /* the answer: interface address to use */
struct rt_metrics_lite rt_rmx; /* metrics used by rx'ing protocols */
- long rt_refcnt; /* # held references */
- struct sockaddr *rt_genmask; /* for generation of cloned routes */
- caddr_t rt_llinfo; /* pointer to link level info cache */
struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */
- struct rtentry *rt_parent; /* cloning parent - UNUSED */
u_int rt_fibnum; /* which FIB */
#ifdef _KERNEL
/* XXX ugly, user apps use this definition but don't have a mtx def */
@@ -326,14 +323,14 @@ struct rt_addrinfo {
#define RT_ADDREF(_rt) do { \
RT_LOCK_ASSERT(_rt); \
KASSERT((_rt)->rt_refcnt >= 0, \
- ("negative refcnt %ld", (_rt)->rt_refcnt)); \
+ ("negative refcnt %d", (_rt)->rt_refcnt)); \
(_rt)->rt_refcnt++; \
} while (0)
#define RT_REMREF(_rt) do { \
RT_LOCK_ASSERT(_rt); \
KASSERT((_rt)->rt_refcnt > 0, \
- ("bogus refcnt %ld", (_rt)->rt_refcnt)); \
+ ("bogus refcnt %d", (_rt)->rt_refcnt)); \
(_rt)->rt_refcnt--; \
} while (0)
Modified: projects/arpv2_merge_1/sys/net/rtsock.c
==============================================================================
--- projects/arpv2_merge_1/sys/net/rtsock.c Fri Dec 12 00:44:19 2008 (r185954)
+++ projects/arpv2_merge_1/sys/net/rtsock.c Fri Dec 12 00:56:00 2008 (r185955)
@@ -497,19 +497,6 @@ route_output(struct mbuf *m, struct sock
(info.rti_info[RTAX_GATEWAY] != NULL &&
info.rti_info[RTAX_GATEWAY]->sa_family >= AF_MAX))
senderr(EINVAL);
- if (info.rti_info[RTAX_GENMASK]) {
- struct radix_node *t;
- t = rn_addmask((caddr_t) info.rti_info[RTAX_GENMASK], 0, 1);
- if (t != NULL &&
- bcmp((char *)(void *)info.rti_info[RTAX_GENMASK] + 1,
- (char *)(void *)t->rn_key + 1,
- ((struct sockaddr *)t->rn_key)->sa_len - 1) == 0)
- info.rti_info[RTAX_GENMASK] =
- (struct sockaddr *)t->rn_key;
- else
- senderr(ENOBUFS);
- }
-
/*
* Verify that the caller has the appropriate privilege; RTM_GET
* is the only operation the non-superuser is allowed.
@@ -540,7 +527,6 @@ route_output(struct mbuf *m, struct sock
&rtm->rtm_rmx, &saved_nrt->rt_rmx);
rtm->rtm_index = saved_nrt->rt_ifp->if_index;
RT_REMREF(saved_nrt);
- saved_nrt->rt_genmask = info.rti_info[RTAX_GENMASK];
RT_UNLOCK(saved_nrt);
}
break;
@@ -624,7 +610,7 @@ route_output(struct mbuf *m, struct sock
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
- info.rti_info[RTAX_GENMASK] = rt->rt_genmask;
+ info.rti_info[RTAX_GENMASK] = 0;
if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
ifp = rt->rt_ifp;
if (ifp) {
@@ -729,8 +715,6 @@ route_output(struct mbuf *m, struct sock
rtm->rtm_index = rt->rt_ifp->if_index;
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, &info);
- if (info.rti_info[RTAX_GENMASK])
- rt->rt_genmask = info.rti_info[RTAX_GENMASK];
/* FALLTHROUGH */
case RTM_LOCK:
/* We don't support locks anymore */
@@ -1272,7 +1256,7 @@ sysctl_dumpentry(struct radix_node *rn,
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
- info.rti_info[RTAX_GENMASK] = rt->rt_genmask;
+ info.rti_info[RTAX_GENMASK] = 0;
if (rt->rt_ifp) {
info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr;
info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
More information about the svn-src-projects
mailing list