Skip to content

Commit 6b9e2d6

Browse files
authored
Merge pull request #867 from liujinhui-job/add_loopback_support
add tcp/udp loopback support, we can send packet through lo dev
2 parents 3dcc3af + d596a1e commit 6b9e2d6

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

freebsd/net/netisr.c

+8
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,14 @@ swi_net(void *arg)
977977
#endif
978978
}
979979

980+
void inline
981+
ff_swi_net_excute(void)
982+
{
983+
struct netisr_workstream *nwsp = DPCPU_ID_PTR(0, nws);
984+
985+
return swi_net((void*)nwsp);
986+
}
987+
980988
static int
981989
netisr_queue_workstream(struct netisr_workstream *nwsp, u_int proto,
982990
struct netisr_work *npwp, struct mbuf *m, int *dosignalp)

freebsd/netinet/in_pcb.c

+5
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,11 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam,
15121512
cred);
15131513
if (error)
15141514
return (error);
1515+
/* Note:
1516+
* LOOPBACK not support rss.
1517+
*/
1518+
if ((ifp->if_softc == NULL) && (ifp->if_flags & IFF_LOOPBACK))
1519+
break;
15151520
rss = ff_rss_check(ifp->if_softc, faddr.s_addr, laddr.s_addr,
15161521
fport, lport);
15171522
if (rss) {

lib/Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ FF_INET6=1
5151
FF_TCPHPTS=1
5252
FF_EXTRA_TCP_STACKS=1
5353

54+
# TCP/UDP loopback.
55+
#FF_LOOPBACK_SUPPORT=1
56+
5457
include ${TOPDIR}/mk/kern.pre.mk
5558

5659
ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
@@ -143,6 +146,11 @@ HOST_CFLAGS+= -DIPSEC
143146
CFLAGS+= -DIPSEC
144147
endif
145148

149+
ifdef FF_LOOPBACK_SUPPORT
150+
HOST_CFLAGS+= -DFF_LOOPBACK_SUPPORT
151+
CFLAGS+= -DFF_LOOPBACK_SUPPORT
152+
endif
153+
146154
HOST_C= ${CC} -c $(HOST_CFLAGS) ${HOST_INCLUDES} ${WERROR} ${PROF} $<
147155

148156

lib/ff_api.symlist

+1
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,4 @@ ff_pthread_create
6363
ff_pthread_join
6464
pcurthread
6565
ff_dpdk_raw_packet_send
66+
ff_swi_net_excute

lib/ff_dpdk_if.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,9 @@ main_loop(void *arg)
21672167
}
21682168

21692169
process_msg_ring(qconf->proc_id, pkts_burst);
2170-
2170+
#ifdef FF_LOOPBACK_SUPPORT
2171+
ff_swi_net_excute();
2172+
#endif
21712173
div_tsc = rte_rdtsc();
21722174

21732175
if (likely(lr->loop != NULL && (!idle || cur_tsc - usch_tsc >= drain_tsc))) {

lib/ff_host_interface.h

+2
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,7 @@ int ff_in_pcbladdr(uint16_t family, void *faddr, uint16_t fport, void *laddr);
7878
int ff_rss_check(void *softc, uint32_t saddr, uint32_t daddr,
7979
uint16_t sport, uint16_t dport);
8080

81+
void ff_swi_net_excute(void);
82+
8183
#endif
8284

0 commit comments

Comments
 (0)