aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2016-01-07 08:07:17 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2016-01-07 08:07:17 +0000
commit8a9f7532b0742c8f48985f2d546795d833524bcd (patch)
treed0867fac9ba4a43537c826ef6e127fa76f729262
parent4332feca4b8144d1842c7ecf98ac4f17bac3c1c6 (diff)
downloadsrc-8a9f7532b0742c8f48985f2d546795d833524bcd.tar.gz
src-8a9f7532b0742c8f48985f2d546795d833524bcd.zip
Convert cxgb/cxgbe to the new routing API.
Discussed with: np
Notes
Notes: svn path=/head/; revision=293309
-rw-r--r--sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c37
-rw-r--r--sys/dev/cxgb/ulp/tom/cxgb_listen.c17
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/cm.c43
-rw-r--r--sys/dev/cxgbe/tom/t4_listen.c42
4 files changed, 64 insertions, 75 deletions
diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
index 7b435607df0c..b98caaedf21f 100644
--- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
+++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <net/route.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
+#include <netinet/in_fib.h>
#include <netinet/in_pcb.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
@@ -264,20 +265,14 @@ void __free_ep(struct iwch_ep_common *epc)
free(epc, M_DEVBUF);
}
-static struct rtentry *
+static int
find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port,
- __be16 peer_port, u8 tos)
+ __be16 peer_port, u8 tos, struct nhop4_extended *pnh4)
{
- struct route iproute;
- struct sockaddr_in *dst = (struct sockaddr_in *)&iproute.ro_dst;
-
- bzero(&iproute, sizeof iproute);
- dst->sin_family = AF_INET;
- dst->sin_len = sizeof *dst;
- dst->sin_addr.s_addr = peer_ip;
-
- rtalloc(&iproute);
- return iproute.ro_rt;
+ struct in_addr addr;
+
+ addr.s_addr = peer_ip;
+ return (fib4_lookup_nh_ext(RT_DEFAULT_FIB, addr, NHR_REF, 0, pnh4));
}
static void
@@ -1293,7 +1288,7 @@ iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
int err = 0;
struct iwch_dev *h = to_iwch_dev(cm_id->device);
struct iwch_ep *ep;
- struct rtentry *rt;
+ struct nhop4_extended nh4;
struct toedev *tdev;
if (is_loopback_dst(cm_id)) {
@@ -1329,28 +1324,28 @@ iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
goto fail2;
/* find a route */
- rt = find_route(cm_id->local_addr.sin_addr.s_addr,
+ err = find_route(cm_id->local_addr.sin_addr.s_addr,
cm_id->remote_addr.sin_addr.s_addr,
cm_id->local_addr.sin_port,
- cm_id->remote_addr.sin_port, IPTOS_LOWDELAY);
- if (!rt) {
+ cm_id->remote_addr.sin_port, IPTOS_LOWDELAY, &nh4);
+ if (err) {
printf("%s - cannot find route.\n", __FUNCTION__);
err = EHOSTUNREACH;
goto fail2;
}
- if (!(rt->rt_ifp->if_flags & IFCAP_TOE)) {
+ if (!(nh4.nh_ifp->if_flags & IFCAP_TOE)) {
printf("%s - interface not TOE capable.\n", __FUNCTION__);
- RTFREE(rt);
+ fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
goto fail2;
}
- tdev = TOEDEV(rt->rt_ifp);
+ tdev = TOEDEV(nh4.nh_ifp);
if (tdev == NULL) {
printf("%s - No toedev for interface.\n", __FUNCTION__);
- RTFREE(rt);
+ fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
goto fail2;
}
- RTFREE(rt);
+ fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
state_set(&ep->com, CONNECTING);
ep->com.local_addr = cm_id->local_addr;
diff --git a/sys/dev/cxgb/ulp/tom/cxgb_listen.c b/sys/dev/cxgb/ulp/tom/cxgb_listen.c
index 933a83c2aaa7..b7d69df6cd21 100644
--- a/sys/dev/cxgb/ulp/tom/cxgb_listen.c
+++ b/sys/dev/cxgb/ulp/tom/cxgb_listen.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/ip.h>
+#include <netinet/in_fib.h>
#include <netinet/in_pcb.h>
#include <netinet/in_var.h>
#include <netinet/tcp_timer.h>
@@ -480,8 +481,8 @@ do_pass_accept_req(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m)
unsigned int tid = GET_TID(req);
struct listen_ctx *lctx = lookup_stid(&td->tid_maps, stid);
struct l2t_entry *e = NULL;
+ struct nhop4_basic nh4;
struct sockaddr_in nam;
- struct rtentry *rt;
struct inpcb *inp;
struct socket *so;
struct port_info *pi;
@@ -525,18 +526,12 @@ do_pass_accept_req(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m)
nam.sin_len = sizeof(nam);
nam.sin_family = AF_INET;
nam.sin_addr = inc.inc_faddr;
- rt = rtalloc1((struct sockaddr *)&nam, 0, 0);
- if (rt == NULL)
+ if (fib4_lookup_nh_basic(RT_DEFAULT_FIB, nam.sin_addr, 0, 0, &nh4) != 0)
REJECT_PASS_ACCEPT();
else {
- struct sockaddr *nexthop;
-
- RT_UNLOCK(rt);
- nexthop = rt->rt_flags & RTF_GATEWAY ? rt->rt_gateway :
- (struct sockaddr *)&nam;
- if (rt->rt_ifp == ifp)
- e = t3_l2t_get(pi, rt->rt_ifp, nexthop);
- RTFREE(rt);
+ nam.sin_addr = nh4.nh_addr;
+ if (nh4.nh_ifp == ifp)
+ e = t3_l2t_get(pi, ifp, (struct sockaddr *)&nam);
if (e == NULL)
REJECT_PASS_ACCEPT(); /* no l2te, or ifp mismatch */
}
diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c
index cb4be71e5615..8af7df5f4ebd 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cm.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cm.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_systm.h>
#include <netinet/in_pcb.h>
#include <netinet/ip.h>
+#include <netinet/in_fib.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp.h>
@@ -86,8 +87,8 @@ static void __state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate);
static void state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate);
static void *alloc_ep(int size, gfp_t flags);
void __free_ep(struct c4iw_ep_common *epc);
-static struct rtentry * find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port,
- __be16 peer_port, u8 tos);
+static int find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port,
+ __be16 peer_port, u8 tos, struct nhop4_extended *pnh4);
static int close_socket(struct c4iw_ep_common *epc, int close);
static int shutdown_socket(struct c4iw_ep_common *epc);
static void abort_socket(struct c4iw_ep *ep);
@@ -201,23 +202,21 @@ done:
}
-static struct rtentry *
+static int
find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port,
- __be16 peer_port, u8 tos)
+ __be16 peer_port, u8 tos, struct nhop4_extended *pnh4)
{
- struct route iproute;
- struct sockaddr_in *dst = (struct sockaddr_in *)&iproute.ro_dst;
+ struct in_addr addr;
+ int err;
CTR5(KTR_IW_CXGBE, "%s:frtB %x, %x, %d, %d", __func__, local_ip,
peer_ip, ntohs(local_port), ntohs(peer_port));
- bzero(&iproute, sizeof iproute);
- dst->sin_family = AF_INET;
- dst->sin_len = sizeof *dst;
- dst->sin_addr.s_addr = peer_ip;
-
- rtalloc(&iproute);
- CTR2(KTR_IW_CXGBE, "%s:frtE %p", __func__, (uint64_t)iproute.ro_rt);
- return iproute.ro_rt;
+
+ addr.s_addr = peer_ip;
+ err = fib4_lookup_nh_ext(RT_DEFAULT_FIB, addr, NHR_REF, 0, pnh4);
+
+ CTR2(KTR_IW_CXGBE, "%s:frtE %d", __func__, err);
+ return err;
}
static int
@@ -2012,7 +2011,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
int err = 0;
struct c4iw_dev *dev = to_c4iw_dev(cm_id->device);
struct c4iw_ep *ep = NULL;
- struct rtentry *rt;
+ struct nhop4_extended nh4;
struct toedev *tdev;
CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id);
@@ -2068,13 +2067,13 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
init_sock(&ep->com);
/* find a route */
- rt = find_route(
+ err = find_route(
cm_id->local_addr.sin_addr.s_addr,
cm_id->remote_addr.sin_addr.s_addr,
cm_id->local_addr.sin_port,
- cm_id->remote_addr.sin_port, 0);
+ cm_id->remote_addr.sin_port, 0, &nh4);
- if (!rt) {
+ if (err) {
CTR2(KTR_IW_CXGBE, "%s:cc7 %p", __func__, ep);
printk(KERN_ERR MOD "%s - cannot find route.\n", __func__);
@@ -2082,7 +2081,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
goto fail2;
}
- if (!(rt->rt_ifp->if_capenable & IFCAP_TOE)) {
+ if (!(nh4.nh_ifp->if_capenable & IFCAP_TOE)) {
CTR2(KTR_IW_CXGBE, "%s:cc8 %p", __func__, ep);
printf("%s - interface not TOE capable.\n", __func__);
@@ -2090,7 +2089,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
err = -ENOPROTOOPT;
goto fail3;
}
- tdev = TOEDEV(rt->rt_ifp);
+ tdev = TOEDEV(nh4.nh_ifp);
if (tdev == NULL) {
@@ -2098,7 +2097,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
printf("%s - No toedev for interface.\n", __func__);
goto fail3;
}
- RTFREE(rt);
+ fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
state_set(&ep->com, CONNECTING);
ep->tos = 0;
@@ -2117,7 +2116,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
fail3:
CTR2(KTR_IW_CXGBE, "%s:ccb %p", __func__, ep);
- RTFREE(rt);
+ fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
fail2:
cm_id->rem_ref(cm_id);
c4iw_put_ep(&ep->com);
diff --git a/sys/dev/cxgbe/tom/t4_listen.c b/sys/dev/cxgbe/tom/t4_listen.c
index 187a9f879f22..5af9260371f8 100644
--- a/sys/dev/cxgbe/tom/t4_listen.c
+++ b/sys/dev/cxgbe/tom/t4_listen.c
@@ -49,9 +49,11 @@ __FBSDID("$FreeBSD$");
#include <net/if_vlan_var.h>
#include <net/route.h>
#include <netinet/in.h>
+#include <netinet/in_fib.h>
#include <netinet/in_pcb.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
+#include <netinet6/in6_fib.h>
#include <netinet6/scope6_var.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
@@ -1095,46 +1097,44 @@ static struct l2t_entry *
get_l2te_for_nexthop(struct port_info *pi, struct ifnet *ifp,
struct in_conninfo *inc)
{
- struct rtentry *rt;
struct l2t_entry *e;
struct sockaddr_in6 sin6;
struct sockaddr *dst = (void *)&sin6;
if (inc->inc_flags & INC_ISIPV6) {
+ struct nhop6_basic nh6;
+
+ bzero(dst, sizeof(struct sockaddr_in6));
dst->sa_len = sizeof(struct sockaddr_in6);
dst->sa_family = AF_INET6;
- ((struct sockaddr_in6 *)dst)->sin6_addr = inc->inc6_faddr;
if (IN6_IS_ADDR_LINKLOCAL(&inc->inc6_laddr)) {
/* no need for route lookup */
e = t4_l2t_get(pi, ifp, dst);
return (e);
}
+
+ if (fib6_lookup_nh_basic(RT_DEFAULT_FIB, &inc->inc6_faddr,
+ 0, 0, 0, &nh6) != 0)
+ return (NULL);
+ if (nh6.nh_ifp != ifp)
+ return (NULL);
+ ((struct sockaddr_in6 *)dst)->sin6_addr = nh6.nh_addr;
} else {
+ struct nhop4_basic nh4;
+
dst->sa_len = sizeof(struct sockaddr_in);
dst->sa_family = AF_INET;
- ((struct sockaddr_in *)dst)->sin_addr = inc->inc_faddr;
- }
- rt = rtalloc1(dst, 0, 0);
- if (rt == NULL)
- return (NULL);
- else {
- struct sockaddr *nexthop;
-
- RT_UNLOCK(rt);
- if (rt->rt_ifp != ifp)
- e = NULL;
- else {
- if (rt->rt_flags & RTF_GATEWAY)
- nexthop = rt->rt_gateway;
- else
- nexthop = dst;
- e = t4_l2t_get(pi, ifp, nexthop);
- }
- RTFREE(rt);
+ if (fib4_lookup_nh_basic(RT_DEFAULT_FIB, inc->inc_faddr, 0, 0,
+ &nh4) != 0)
+ return (NULL);
+ if (nh4.nh_ifp != ifp)
+ return (NULL);
+ ((struct sockaddr_in *)dst)->sin_addr = nh4.nh_addr;
}
+ e = t4_l2t_get(pi, ifp, dst);
return (e);
}