Add L2TP offloading support

Fixes #13

Also-by: Dominique Martinet <asmadeus@codewreck.org>
This commit is contained in:
Samuel Thibault 2023-04-23 13:50:04 +02:00
parent 13d7080ac1
commit a9e18411d3
8 changed files with 715 additions and 35 deletions

View file

@ -13,6 +13,9 @@
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <net/if.h>
#include <linux/ppp_defs.h>
#include <linux/if_ppp.h>
#include <libcli.h>
#define VERSION "2.4.1"
@ -446,6 +449,18 @@ typedef struct
uint32_t jitteravg;
// time in milliseconds of the last fragment.
uint64_t prev_time;
// l2tp PPPoL2TP socket
int pppox_fd;
struct pppol2tp_ioc_stats last_stats;
// ppp channel
int ppp_chan_fd;
// ppp interface
int ppp_if_fd;
// ppp interface index
int ppp_if_idx;
} sessionlocalt;
// session flags
@ -479,6 +494,12 @@ typedef struct
}
tunnelt;
typedef struct
{
int l2tp_fd; // kernel acceleration UDP socket
}
tunnellocalt;
// 164 bytes per radius session
typedef struct // outstanding RADIUS requests
{
@ -821,6 +842,7 @@ typedef struct
uint32_t dhcp6_server_duid; // DUID of dhcpv6 server (see rfc3315)
uint32_t dns6_lifetime; // RDNSS lifetime default 1200 (see rfc6106, rfc4861) (MaxRtrAdvInterval <= Lifetime <= 2*MaxRtrAdvInterval)
char default_ipv6_domain_list[255];
int kernel_accel; // Enable kernel-accelerated support
} configt;
enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IPv4, IPv6 };
@ -1008,6 +1030,7 @@ int sessionsetup(sessionidt s, tunnelidt t);
int run_plugins(int plugin_type, void *data);
void rebuild_address_pool(void);
void throttle_session(sessionidt s, int rate_in, int rate_out);
int load_tunnel(tunnelidt, tunnelt *);
int load_session(sessionidt, sessiont *);
void become_master(void); // We're the master; kick off any required master initializations.
@ -1028,6 +1051,7 @@ extern tunnelt *tunnel;
extern bundlet *bundle;
extern sessiont *session;
extern sessionlocalt *sess_local;
extern tunnellocalt *tunn_local;
extern ippoolt *ip_address_pool;
#define sessionfree (session[0].next)
@ -1057,7 +1081,11 @@ struct event_data {
FD_TYPE_BGP,
FD_TYPE_RTNETLINK,
FD_TYPE_PPPOEDISC,
FD_TYPE_PPPOESESS
FD_TYPE_PPPOESESS,
FD_TYPE_L2TP,
FD_TYPE_PPPOX,
FD_TYPE_PPP_CHAN,
FD_TYPE_PPP_IF,
} type;
int index; // for RADIUS, BGP, UDP
};