Attempt to hack in acceleration for PPPoE

This commit is contained in:
Tassilo Schweyer 2025-04-29 00:43:40 +02:00
parent 0c9338b03a
commit 57004c5744
4 changed files with 40 additions and 9 deletions

View file

@ -1016,7 +1016,7 @@ static int create_ppp_socket(int udp_fd, uint32_t tid, uint32_t peer_tid, uint32
return pppox_fd;
}
static int create_kernel_ppp_chan(sessionidt s, int pppox_fd);
//
// Create the kernel session and PPPoX socket for this session
static int create_kernel_pppox(sessionidt s)
@ -1024,7 +1024,14 @@ static int create_kernel_pppox(sessionidt s)
tunnelidt t = session[s].tunnel;
if (t == TUNNEL_ID_PPPOE) {
return create_kernel_pppoe_socket(s);
int ret = create_kernel_pppoe_socket(s);
if (ret < 0) {
return ret;
} else {
create_kernel_ppp_chan(s, ret);
return ret;
}
}
if (tunn_local[t].l2tp_fd < 0)
@ -1301,11 +1308,16 @@ int create_kernel_bridge(sessionidt s, sessionidt fwds)
LOG(3, s, t, "Starting kernel-accelerated bridge between %u and %u\n", s, fwds);
LOG(3, s, t, "Setting up primary side channel\n");
int ppp_chan_fd = create_kernel_ppp_chan(s, pppox_fd);
if (ppp_chan_fd < 0)
goto err_fwd_pppox_fd;
LOG(3, s, t, "Fetching secondary side channel (already existing) fwd_fd=%d fwd_pppox_fd=%d\n", fwds, fwd_pppox_fd);
int fwd_idx = get_kernel_ppp_chan(fwds, fwd_pppox_fd);
LOG(3, s, t, "Got channel ID = %d\n", fwd_idx);
LOG(3, s, t, "Performing bridging\n");
int ret = ioctl(ppp_chan_fd, PPPIOCBRIDGECHAN, &fwd_idx);
close(ppp_chan_fd);
@ -1392,7 +1404,7 @@ static int delete_kernel_accel(sessionidt s)
// Enable (set=1) or disable (set=0) kernel PPP acceleration
// This basically calls create/delete_kernel_accel, but also updates routes
// If now is 0, we may delay this if we have already made a lot of switches since last cleanup
static void set_kernel_accel(sessionidt s, int set, int nodelay)
void set_kernel_accel(sessionidt s, int set, int nodelay)
{
if (set && !can_kernel_accel(s))
/* Still cannot enable it */
@ -1506,10 +1518,15 @@ static void apply_kernel_stats(sessionidt s)
/* It is free */
return;
if (session[s].tunnel == TUNNEL_ID_PPPOE)
/* it is PPPoE */
return;
if (sess_local[s].pppox_fd < 0)
/* It does not have kernel acceleration */
return;
struct pppol2tp_ioc_stats stats, *last_stats = &sess_local[s].last_stats;
int ret = ioctl(sess_local[s].pppox_fd, PPPIOCGL2TPSTATS, &stats);
if (ret < 0)