Skip to content

Commit

Permalink
automatic commit at releng box
Browse files Browse the repository at this point in the history
  • Loading branch information
mc36 committed Dec 22, 2024
1 parent 0f826cf commit 2428cf9
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cfg/p4lang4.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xdp punting route mpls bundle vlan pppoe eompls bridge vpls evpn hairpin sgt loconn pmtud vrfysrc gre l2tp l3tp gtp nsh polka gretap pppoetap l2tptap l3tptap pckoudp vxlan
xdp punting route mpls bundle vlan pppoe eompls bridge vpls evpn hairpin sgt loconn pmtud vrfysrc gre l2tp l3tp gtp nsh polka gretap pppoetap l2tptap l3tptap pckoudp vxlan pwhe

qemu-img create -f qcow2 -o backing_file=../img/p4xdp.img,backing_fmt=raw $fn$
qemu-system-x86_64 -monitor none -serial stdio -nographic -no-reboot -enable-kvm -cpu host -smp cores=2,threads=1,sockets=1 -drive file=$fn$,format=qcow2,cache=unsafe -m 1024 $nc$
Expand Down
24 changes: 24 additions & 0 deletions misc/native/p4xdp_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ struct {
put32msb(bufD, bufP, label); \
neik = resm->hop; \
goto ethtyp_tx; \
case 7: \
if (bpf_xdp_adjust_head(ctx, bufP) != 0) goto drop; \
prt = resm->port; \
continue; \
case 8: \
goto cpu; \
default: \
goto drop;

Expand Down Expand Up @@ -1163,6 +1169,24 @@ __u32 xdp_router(struct xdp_md *ctx) {
putUdpHeader(neir);
putIpv6header(neir, IP_PROTOCOL_UDP);
break;
case 11: // pwhe
bufP -= sizeof(macaddr) + 16;
if (bpf_xdp_adjust_head(ctx, bufP) != 0) goto drop;
bufP = sizeof(macaddr) + 16;
revalidatePacket(bufP + 2);
bufP -= sizeof(macaddr);
__builtin_memcpy(&bufD[bufP], &macaddr, sizeof(macaddr));
bufP -= 4;
tmp = 0x1ff | (neir->trgPort << 12);
put32msb(bufD, bufP, tmp);
bufP -= 4;
tmp = 0xff | (neir->srcPort << 12);
put32msb(bufD, bufP, tmp);
ethtyp = ETHERTYPE_MPLS_UCAST;
bufP -= 2;
put16msb(bufD, bufP, ethtyp);
__builtin_memcpy(&macaddr[0], neir->mac2, sizeof(neir->mac2));
break;
default:
goto drop;
}
Expand Down
71 changes: 71 additions & 0 deletions misc/native/p4xdp_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,56 @@ int doOneCommand(unsigned char* buf) {
}
return 0;
}
if (strcmp(arg[0], "pwhenei4") == 0) {
inet_pton(AF_INET, arg[3], buf2);
rou4.vrf = atoi(arg[5]);
memcpy(rou4.addr, buf2, sizeof(rou4.addr));
rou4.bits = routes_bits + (sizeof(rou4.addr) * 8);
rour.cmd = 1;
i = rour.hop = atoi(arg[2]);
str2mac(&neir.macs[0], arg[4]);
str2mac(&neir.macs[6], arg[6]);
neir.port = atoi(arg[7]);
neir.aclport = atoi(arg[8]);
str2mac(&neir.mac2[0], arg[9]);
str2mac(&neir.mac2[6], arg[10]);
neir.srcPort = atoi(arg[11]);
neir.trgPort = atoi(arg[12]);
neir.cmd = 11;
if (del == 0) {
if (bpf_map_delete_elem(route4_fd, &rou4) != 0) warn("error removing entry");
if (bpf_map_delete_elem(neighs_fd, &i) != 0) warn("error removing entry");
} else {
if (bpf_map_update_elem(route4_fd, &rou4, &rour, BPF_ANY) != 0) warn("error setting entry");
if (bpf_map_update_elem(neighs_fd, &i, &neir, BPF_ANY) != 0) warn("error setting entry");
}
return 0;
}
if (strcmp(arg[0], "pwhenei6") == 0) {
inet_pton(AF_INET6, arg[3], buf2);
rou6.vrf = atoi(arg[5]);
memcpy(rou6.addr, buf2, sizeof(rou6.addr));
rou6.bits = routes_bits + (sizeof(rou6.addr) * 8);
rour.cmd = 1;
i = rour.hop = atoi(arg[2]);
str2mac(&neir.macs[0], arg[4]);
str2mac(&neir.macs[6], arg[6]);
neir.port = atoi(arg[7]);
neir.aclport = atoi(arg[8]);
str2mac(&neir.mac2[0], arg[9]);
str2mac(&neir.mac2[6], arg[10]);
neir.srcPort = atoi(arg[11]);
neir.trgPort = atoi(arg[12]);
neir.cmd = 11;
if (del == 0) {
if (bpf_map_delete_elem(route6_fd, &rou6) != 0) warn("error removing entry");
if (bpf_map_delete_elem(neighs_fd, &i) != 0) warn("error removing entry");
} else {
if (bpf_map_update_elem(route6_fd, &rou6, &rour, BPF_ANY) != 0) warn("error setting entry");
if (bpf_map_update_elem(neighs_fd, &i, &neir, BPF_ANY) != 0) warn("error setting entry");
}
return 0;
}
if (strcmp(arg[0], "myaddr4") == 0) {
inet_pton(AF_INET, arg[2], buf2);
rou4.vrf = atoi(arg[5]);
Expand Down Expand Up @@ -763,6 +813,27 @@ int doOneCommand(unsigned char* buf) {
}
return 0;
}
if (strcmp(arg[0], "pwhelab") == 0) {
i = atoi(arg[2]);
labr.port = atoi(arg[3]);
labr.cmd = 7;
if (del == 0) {
if (bpf_map_delete_elem(labels_fd, &i) != 0) warn("error removing entry");
} else {
if (bpf_map_update_elem(labels_fd, &i, &labr, BPF_ANY) != 0) warn("error setting entry");
}
return 0;
}
if (strcmp(arg[0], "cpulabel") == 0) {
i = atoi(arg[2]);
labr.cmd = 8;
if (del == 0) {
if (bpf_map_delete_elem(labels_fd, &i) != 0) warn("error removing entry");
} else {
if (bpf_map_update_elem(labels_fd, &i, &labr, BPF_ANY) != 0) warn("error setting entry");
}
return 0;
}
if (strcmp(arg[0], "hairpin") == 0) {
o = atoi(arg[2]);
bunn.cmd = 2;
Expand Down
5 changes: 3 additions & 2 deletions misc/native/p4xdp_tab.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ struct routes_res {
};

struct neigh_res {
__u32 cmd; // 1=rawip, 2=pppoe, 3=gre4, 4=gre6, 5=l2tp4, 6=l2tp6, 7=l3tp4, 8=l3tp6, 9=gtp4, 10=gtp6
__u32 cmd; // 1=rawip, 2=pppoe, 3=gre4, 4=gre6, 5=l2tp4, 6=l2tp6, 7=l3tp4, 8=l3tp6, 9=gtp4, 10=gtp6, 11=pwhe
__u8 macs[12];
__u8 mac2[12];
__u32 port;
__u32 aclport;
__u32 sess;
Expand All @@ -68,7 +69,7 @@ struct neigh_res {
};

struct label_res {
__u32 cmd; // 1=route, 2=pop, 3=swap, 4=xconn, 5=vpls, 6=push
__u32 cmd; // 1=route, 2=pop, 3=swap, 4=xconn, 5=vpls, 6=push, 7=pwhe, 8=punt
__u32 ver;
__u32 hop;
__u32 vrf;
Expand Down
2 changes: 1 addition & 1 deletion misc/native/p4xdp_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void doStatLoop() {
FILE *commands = fdopen(commandSock, "w");
if (commands == NULL) err("failed to open file");
fprintf(commands, "platform p4xdp\r\n");
fprintf(commands, "capabilities punting route mpls bundle vlan pppoe eompls bridge vpls evpn hairpin sgt loconn pmtud vrfysrc gre l2tp l3tp gtp nsh polka gretap pppoetap l2tptap l3tptap pckoudp vxlan\r\n");
fprintf(commands, "capabilities punting route mpls bundle vlan pppoe eompls bridge vpls evpn hairpin sgt loconn pmtud vrfysrc gre l2tp l3tp gtp nsh polka gretap pppoetap l2tptap l3tptap pckoudp vxlan pwhe\r\n");
for (int i = 0; i < dataPorts; i++) fprintf(commands, "portname %i %s\r\n", i, ifaceName[i]);
fprintf(commands, "cpuport %i\r\n", cpuPort);
fprintf(commands, "dynrange 32768 1073741823\r\n");
Expand Down
3 changes: 3 additions & 0 deletions src/org/freertr/serv/servP4langConn.java
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,9 @@ private void doNeighs(boolean ipv4, servP4langIfc ifc, ipIfc ipi) {
if (hop == null) {
return;
}
if (hop.mac == null) {
return;
}
ll = servP4langUtil.getLabel(ntry);
}
String afi;
Expand Down

0 comments on commit 2428cf9

Please sign in to comment.