From c701745d4e09d4dfe8c3b64a186241eb7748272d Mon Sep 17 00:00:00 2001 From: Jatin <84621253+h0x0er@users.noreply.github.com> Date: Sat, 16 Aug 2025 01:23:43 +0530 Subject: [PATCH 1/2] added network programs --- package.json | 4 ++ snippets/progs-cgroup.code-snippets | 9 ++++ snippets/progs-network.code-snippets | 74 ++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 snippets/progs-network.code-snippets diff --git a/package.json b/package.json index d81e9ec..e91097e 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,10 @@ { "language": "c", "path": "./snippets/progs-tracing.code-snippets" + }, + { + "language": "c", + "path": "./snippets/progs-network.code-snippets" } ] }, diff --git a/snippets/progs-cgroup.code-snippets b/snippets/progs-cgroup.code-snippets index eb3ea8a..cd0ce9f 100644 --- a/snippets/progs-cgroup.code-snippets +++ b/snippets/progs-cgroup.code-snippets @@ -53,4 +53,13 @@ "int handle_sysctl(struct bpf_sysctl *ctx){ return 1; }" ] }, + "create cgroup sock-ops prog": { + "scope": "c", + "description": "", + "prefix": "bpf-prog-cgroup-sock-ops", + "body": [ + "SEC(\"sockops\")", + "int handle_sockops(struct bpf_sock_ops *ctx){ return 1; }" + ] + }, } \ No newline at end of file diff --git a/snippets/progs-network.code-snippets b/snippets/progs-network.code-snippets new file mode 100644 index 0000000..b83468d --- /dev/null +++ b/snippets/progs-network.code-snippets @@ -0,0 +1,74 @@ +{ + "create classifier prog (tc/tcx)": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_SCHED_CLS/", + "prefix": "bpf-prog-tc", + "body": [ + "SEC(\"${1|tc/egress,tc/ingress,tcx/egress,tcx/ingress|}\")", + "int handle_${1/[\\/]/_/}(struct __sk_buff *skb){ return -1; }" + ] + }, + "create xdp prog": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_XDP/#usage", + "prefix": "bpf-prog-xdp", + "body": [ + "SEC(\"xdp\")", + "int handle_xdp(struct xdp_md *ctx){ return XDP_PASS; }" + ] + }, + "create sk_skb prog": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_SK_SKB/", + "prefix": "bpf-prog-sk-skb", + "body": [ + "SEC(\"sk_skb/${1|stream_parser,stream_verdict|}\")", + "int handle_$1(struct __sk_buff *skb){ return 1; }" + ] + }, + "create sk_msg prog": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_SK_MSG/", + "prefix": "bpf-prog-sk-msg", + "body": [ + "SEC(\"sk_msg\")", + "int handle_skmsg(struct sk_msg_md *msg){ return SK_PASS; }" + ] + }, + "create sk_lookup prog": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_SK_LOOKUP/", + "prefix": "bpf-prog-sk-lookup", + "body": [ + "SEC(\"sk_lookup\")", + "int handle_sklookup(struct bpf_sk_lookup *ctx){ return SK_PASS; }" + ] + }, + "create sk_reuseport prog": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_SK_REUSEPORT/#usage", + "prefix": "bpf-prog-sk-reuseport", + "body": [ + "SEC(\"${1|sk_reuseport,sk_reuseport/migrate|}\")", + "int handle_sk_reuseport(struct sk_reuseport_md *ctx){ return SK_PASS; }" + ] + }, + "create flow_dissector prog": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_FLOW_DISSECTOR/#context", + "prefix": "bpf-prog-flow-dissector", + "body": [ + "SEC(\"flow_dissector\")", + "int handle_dissector(struct __sk_buff *skb){ return BPF_OK; }" + ] + }, + "create netfliter prog": { + "scope": "c", + "description": "Refer: https://docs.ebpf.io/linux/program-type/BPF_PROG_TYPE_NETFILTER/", + "prefix": "bpf-prog-netfilter", + "body": [ + "SEC(\"netfilter\")", + "int do_netfilter(struct bpf_nf_ctx *ctx){ return NF_ACCEPT; }" + ] + }, +} \ No newline at end of file From 1d8919162b855a49887c7cb8838dbe608dfe3343 Mon Sep 17 00:00:00 2001 From: Jatin <84621253+h0x0er@users.noreply.github.com> Date: Sat, 16 Aug 2025 09:03:36 +0530 Subject: [PATCH 2/2] updates --- .github/workflows/release.yml | 6 ++++++ README.md | 36 ++++++++++++++++++++--------------- package.json | 2 +- snippets/maps.code-snippets | 18 ++++++++++-------- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7802aec..d95a193 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,3 +37,9 @@ jobs: VSIX_FILE=$(ls *.vsix | head -n 1) echo "Uploading $VSIX_FILE to release ${{ github.event.release.tag_name }}" gh release upload "${{ github.event.release.tag_name }}" "$VSIX_FILE" --clobber + + - name: Publish to VSCode Marketplace + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + run: | + vsce publish -p "$VSCE_PAT" \ No newline at end of file diff --git a/README.md b/README.md index 90abeb2..6afcd9a 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,35 @@ # eBPF Snippets -Code-snippets for developing eBPF programs +Code snippets for developing **eBPF** programs. - +
+
+
+
+
+
+