Skip to content

Commit

Permalink
ppp: Add XDP support to ingress vlan_id
Browse files Browse the repository at this point in the history
  • Loading branch information
acassen committed Feb 14, 2024
1 parent 51305c2 commit 9cb77ed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bpf/gtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ struct gtp_rt_rule {
__be32 daddr;
__be32 dst_key;
__u8 ifindex;
__u16 vlan_id;

/* Some stats */
__u64 packets;
Expand Down
8 changes: 8 additions & 0 deletions src/gtp_xdp_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ gtp_xdp_ppp_rule_set(struct gtp_rt_rule *r, gtp_teid_t *t, spppoe_t *spppoe)
gtp_conn_t *c = s->conn;
gtp_router_t *rtr = c->ctx;
gtp_server_t *srv = &rtr->gtpu;
ip_vrf_t *vrf = s->apn->vrf;
__u16 vlan_id = 0;
int i;

vlan_id = (vrf) ? vrf->encap_vlan_id : 0;
if (__test_bit(GTP_TEID_FL_INGRESS, &t->flags))
vlan_id = (vrf) ? vrf->decap_vlan_id : 0;

for (i = 0; i < nr_cpus; i++) {
/* PPP related */
memcpy(r[i].h_src, &spppoe->hw_src, ETH_ALEN);
Expand All @@ -111,6 +117,8 @@ gtp_xdp_ppp_rule_set(struct gtp_rt_rule *r, gtp_teid_t *t, spppoe_t *spppoe)
r[i].teid = t->id;
r[i].saddr = inet_sockaddrip4(&srv->addr);
r[i].daddr = t->ipv4;
r[i].vlan_id = vlan_id;
r[i].ifindex = spppoe->pppoe->ifindex;
r[i].dst_key = 0;
r[i].packets = 0;
r[i].bytes = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/gtp_xdp_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,19 @@ gtp_xdp_rt_rule_set(struct gtp_rt_rule *r, gtp_teid_t *t)
ip_vrf_t *vrf = s->apn->vrf;
__be32 dst_key = (vrf) ? vrf->id : 0;
__u8 flags = __test_bit(IP_VRF_FL_IPIP_BIT, &vrf->flags) ? GTP_RT_FL_IPIP : 0;
__u16 vlan_id = 0;
int i;

vlan_id = (vrf) ? vrf->encap_vlan_id : 0;
if (__test_bit(GTP_TEID_FL_INGRESS, &t->flags))
vlan_id = (vrf) ? vrf->decap_vlan_id : 0;

for (i = 0; i < nr_cpus; i++) {
r[i].teid = t->id;
r[i].saddr = inet_sockaddrip4(&srv->addr);
r[i].daddr = t->ipv4;
r[i].dst_key = dst_key;
r[i].vlan_id = vlan_id;
r[i].packets = 0;
r[i].bytes = 0;
r[i].flags = flags;
Expand Down
1 change: 1 addition & 0 deletions src/include/gtp_xdp_rt.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct gtp_rt_rule {
__be32 daddr;
__be32 dst_key;
__u8 ifindex;
__u16 vlan_id;

/* Some stats */
__u64 packets;
Expand Down

0 comments on commit 9cb77ed

Please sign in to comment.