Merge pull request #867 from liujinhui-job/add_loopback_support

add tcp/udp loopback support, we can send packet through lo dev
This commit is contained in:
johnjiang 2025-03-27 11:10:45 +08:00 committed by GitHub
commit 6b9e2d694f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 27 additions and 1 deletions

View File

@ -977,6 +977,14 @@ out:
#endif
}
void inline
ff_swi_net_excute(void)
{
struct netisr_workstream *nwsp = DPCPU_ID_PTR(0, nws);
return swi_net((void*)nwsp);
}
static int
netisr_queue_workstream(struct netisr_workstream *nwsp, u_int proto,
struct netisr_work *npwp, struct mbuf *m, int *dosignalp)

View File

@ -1512,6 +1512,11 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam,
cred);
if (error)
return (error);
/* Note:
* LOOPBACK not support rss.
*/
if ((ifp->if_softc == NULL) && (ifp->if_flags & IFF_LOOPBACK))
break;
rss = ff_rss_check(ifp->if_softc, faddr.s_addr, laddr.s_addr,
fport, lport);
if (rss) {

View File

@ -51,6 +51,9 @@ FF_INET6=1
FF_TCPHPTS=1
FF_EXTRA_TCP_STACKS=1
# TCP/UDP loopback.
#FF_LOOPBACK_SUPPORT=1
include ${TOPDIR}/mk/kern.pre.mk
ifneq ($(shell pkg-config --exists libdpdk && echo 0),0)
@ -143,6 +146,11 @@ HOST_CFLAGS+= -DIPSEC
CFLAGS+= -DIPSEC
endif
ifdef FF_LOOPBACK_SUPPORT
HOST_CFLAGS+= -DFF_LOOPBACK_SUPPORT
CFLAGS+= -DFF_LOOPBACK_SUPPORT
endif
HOST_C= ${CC} -c $(HOST_CFLAGS) ${HOST_INCLUDES} ${WERROR} ${PROF} $<

View File

@ -63,3 +63,4 @@ ff_pthread_create
ff_pthread_join
pcurthread
ff_dpdk_raw_packet_send
ff_swi_net_excute

View File

@ -2167,7 +2167,9 @@ main_loop(void *arg)
}
process_msg_ring(qconf->proc_id, pkts_burst);
#ifdef FF_LOOPBACK_SUPPORT
ff_swi_net_excute();
#endif
div_tsc = rte_rdtsc();
if (likely(lr->loop != NULL && (!idle || cur_tsc - usch_tsc >= drain_tsc))) {

View File

@ -78,5 +78,7 @@ int ff_in_pcbladdr(uint16_t family, void *faddr, uint16_t fport, void *laddr);
int ff_rss_check(void *softc, uint32_t saddr, uint32_t daddr,
uint16_t sport, uint16_t dport);
void ff_swi_net_excute(void);
#endif