Skip to content

Commit 773337c

Browse files
committed
Merge remote-tracking branch 'up/master'
2 parents 7b5d789 + 941262c commit 773337c

14 files changed

Lines changed: 760 additions & 53 deletions

File tree

.github/workflows/dco-welcome.yml

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,5 @@ on:
66

77
jobs:
88
dco-help:
9-
runs-on: ubuntu-latest
10-
permissions:
11-
contents: read
12-
issues: write
13-
pull-requests: write
14-
if: |
15-
github.event.check_run.conclusion == 'failure' &&
16-
contains(github.event.check_run.name, 'DCO') &&
17-
github.event.check_run.pull_requests[0] != null
18-
steps:
19-
- name: Load PR Context
20-
id: pr-context
21-
uses: actions/github-script@v7
22-
with:
23-
script: |
24-
const prs = context.payload.check_run.pull_requests || [];
25-
if (prs.length === 0) {
26-
core.setOutput('should_comment', 'false');
27-
return;
28-
}
29-
30-
const prNumber = prs[0].number;
31-
const { data: pr } = await github.rest.pulls.get({
32-
owner: context.repo.owner,
33-
repo: context.repo.repo,
34-
pull_number: prNumber,
35-
});
36-
37-
const shouldComment = ['FIRST_TIME_CONTRIBUTOR', 'NONE'].includes(pr.author_association);
38-
core.setOutput('pr_number', String(prNumber));
39-
core.setOutput('should_comment', shouldComment ? 'true' : 'false');
40-
41-
- name: Post DCO Instructions
42-
if: steps.pr-context.outputs.should_comment == 'true'
43-
uses: peter-evans/create-or-update-comment@v3
44-
with:
45-
issue-number: ${{ steps.pr-context.outputs.pr_number }}
46-
body: |
47-
Welcome to the project, @${{ github.actor }}!
48-
49-
It looks like this is your first contribution. We noticed the **DCO (Developer Certificate of Origin)** check might fail if your commits aren't signed.
50-
51-
To fix this, please ensure every commit has a `Signed-off-by: Name <email>` line. You can do this automatically by using the `-s` flag:
52-
`git commit -s -m "Your message"`
53-
54-
For existing commits, you can fix them with:
55-
`git commit --amend --signoff` or `git rebase -i HEAD~N --signoff` (where N is the number of commits)
56-
The Developer Community DCO guide also provides helpful tips on fixing DCO inconveniences. Setting a commit hook in the git repository will automate adding the DCO signoff.
57-
See https://github.com/p4lang/governance/wiki/P4-DCO-Guidelines for information.
9+
# https://github.com/p4lang/.github/blob/main/.github/workflows/dco-welcome-reusable.yml
10+
uses: p4lang/.github/.github/workflows/dco-welcome-reusable.yml@main
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: P4 Tutorials CI
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
push:
7+
branches: [ master ]
8+
# Add concurrency so only most recent push have CI
9+
concurrency:
10+
group: p4-tutorials-ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test-exercise:
15+
timeout-minutes: 30
16+
runs-on: ubuntu-latest
17+
# We use need a privileged container because P4 tests need to create veth interfaces
18+
container:
19+
image: p4lang/p4c:latest
20+
options: --privileged
21+
strategy:
22+
matrix:
23+
exercise: [basic, basic_tunnel] # Add more exercises here for future tests
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Install build dependencies
30+
run: |
31+
apt-get update
32+
apt-get install -y make python3-pip sudo libboost-iostreams-dev libboost-graph-dev
33+
pip3 install protobuf==3.20.3 grpcio grpcio-tools googleapis-common-protos scapy
34+
35+
- name: Run PTF Tests
36+
run: |
37+
chmod +x exercises/${{ matrix.exercise }}/runptf.sh
38+
cd exercises/${{ matrix.exercise }}
39+
make test
40+
# Retain logs in case runs fail
41+
- name: Upload Logs
42+
if: always()
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: p4-logs-${{ matrix.exercise }}
46+
path: exercises/${{ matrix.exercise }}/logs/
47+

bin/veth_setup.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# Copyright 2017 Andy Fingerhut
4+
5+
# This script was originally copied from the location below, then
6+
# modified:
7+
#
8+
# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_setup.sh
9+
10+
for idx in 0 1 2 3 4 5 6 7 8; do
11+
intf0="veth$(($idx*2))"
12+
intf1="veth$(($idx*2+1))"
13+
if ! ip link show $intf0 &> /dev/null; then
14+
ip link add name $intf0 type veth peer name $intf1
15+
ip link set dev $intf0 up
16+
ip link set dev $intf1 up
17+
18+
# Set the MTU of these interfaces to be larger than default of
19+
# 1500 bytes, so that P4 behavioral-model testing can be done
20+
# on jumbo frames.
21+
ip link set $intf0 mtu 9500
22+
ip link set $intf1 mtu 9500
23+
############################################################
24+
# ifconfig is deprecated, and no longer installed by default
25+
# in Ubuntu Linux minimal installs starting with Ubuntu 18.04
26+
# LTS.
27+
#ifconfig $intf0 mtu 9500 up
28+
#ifconfig $intf1 mtu 9500 up
29+
############################################################
30+
31+
# Disable IPv6 on the interfaces, so that the Linux kernel
32+
# will not automatically send IPv6 MDNS, Router Solicitation,
33+
# and Multicast Listener Report packets on the interface,
34+
# which can make P4 program debugging more confusing.
35+
#
36+
# Testing indicates that we can still send IPv6 packets across
37+
# such interfaces, both from scapy to simple_switch, and from
38+
# simple_switch out to scapy sniffing.
39+
#
40+
# https://superuser.com/questions/356286/how-can-i-switch-off-ipv6-nd-ra-transmissions-in-linux
41+
sysctl -q net.ipv6.conf.${intf0}.disable_ipv6=1
42+
sysctl -q net.ipv6.conf.${intf1}.disable_ipv6=1
43+
fi
44+
done

bin/veth_teardown.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
# Copyright 2019 Andy Fingerhut
4+
#
5+
6+
# This script was copied from the location below, for convenience of
7+
# p4-guide users:
8+
#
9+
# https://github.com/p4lang/behavioral-model/blob/master/tools/veth_teardown.sh
10+
11+
for idx in 0 1 2 3 4 5 6 7 8; do
12+
intf="veth$(($idx*2))"
13+
if ip link show $intf &> /dev/null; then
14+
ip link delete $intf type veth
15+
fi
16+
done

exercises/basic/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
ptf.log
3+
ptf.pcap
4+
ss-log.txt

exercises/basic/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ BMV2_SWITCH_EXE = simple_switch_grpc
33
TOPO = pod-topo/topology.json
44

55
include ../../utils/Makefile
6+
7+
test: dirs
8+
./runptf.sh

exercises/basic/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ make stop
189189
Congratulations, your implementation works! Move onto the next assignment
190190
[Basic Tunneling](../basic_tunnel)
191191

192-
193192
## Relevant Documentation
194193

195194
The documentation for P4_16 and P4Runtime is available [here](https://p4.org/specifications/)

0 commit comments

Comments
 (0)