Skip to content
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1935495
feat: iptables block using LSM BPF
santhoshmprabhu Jul 29, 2025
9452ce6
feat: makefile changes
santhoshmprabhu Jul 29, 2025
9ac5fa6
chore: cleanup
santhoshmprabhu Jul 29, 2025
1af271c
Update bpf-prog/block-iptables/bpf/src/block_iptables.bpf.c
santhoshmprabhu Jul 29, 2025
cf3038e
chore: fix const
santhoshmprabhu Jul 29, 2025
50dd315
fix: dockerfiles, bug
santhoshmprabhu Jul 29, 2025
6cc55d5
test: add test for bpf attach/detach
santhoshmprabhu Jul 30, 2025
ce9e3e5
Merge remote-tracking branch 'origin/master' into sanprabhu/iptables-…
santhoshmprabhu Jul 30, 2025
0c34970
feat: add event tracking
santhoshmprabhu Jul 30, 2025
27e426a
feat: add event counting
santhoshmprabhu Jul 30, 2025
fd161cc
chore: dockerfiles
santhoshmprabhu Jul 30, 2025
0e369c6
fix: nolint for generated code
santhoshmprabhu Jul 30, 2025
7276e8d
fix: nolint for generated code
santhoshmprabhu Jul 30, 2025
ae83548
fix: golangci skip
santhoshmprabhu Jul 30, 2025
55cd88f
fix:skip directory with generated code
santhoshmprabhu Jul 30, 2025
4169299
chore:skip block iptales generated code
santhoshmprabhu Jul 31, 2025
5e9b829
chore: fix
santhoshmprabhu Jul 31, 2025
722f12b
fix: run go generate first
santhoshmprabhu Jul 31, 2025
2d0928e
fix: use installed go
santhoshmprabhu Jul 31, 2025
e004bec
fix: install bpf libraries
santhoshmprabhu Jul 31, 2025
37dc402
fix: remove file
santhoshmprabhu Jul 31, 2025
9b86fdb
fix: roll back linter changes
santhoshmprabhu Jul 31, 2025
88f4302
fix: add code generation to tests
santhoshmprabhu Aug 1, 2025
37d43ca
chore: switch to dual license
santhoshmprabhu Aug 1, 2025
a9737ba
fix: run generate before lint
santhoshmprabhu Aug 1, 2025
d1df331
fix: install libs
santhoshmprabhu Aug 1, 2025
8a082d1
fix: fix linting, address some comments
santhoshmprabhu Aug 1, 2025
85ec5ba
fix: address comments, fix lint
santhoshmprabhu Aug 2, 2025
91d7063
fix: missed change
santhoshmprabhu Aug 2, 2025
2999342
fix: compile only on linux
santhoshmprabhu Aug 2, 2025
9a436c4
fix: compile only on linux
santhoshmprabhu Aug 2, 2025
17b8ad4
fix: address comments
santhoshmprabhu Aug 5, 2025
ea38462
fix: address comments
santhoshmprabhu Aug 5, 2025
e3efa6d
Merge remote-tracking branch 'origin/master' into sanprabhu/iptables-…
santhoshmprabhu Aug 6, 2025
bddfa2e
chore: dockerfiles
santhoshmprabhu Aug 6, 2025
aa8a4ba
fix: address comments
santhoshmprabhu Aug 6, 2025
c8dca6c
chore:dockerfiles
santhoshmprabhu Aug 6, 2025
60e1272
Merge remote-tracking branch 'origin/master' into sanprabhu/iptables-…
santhoshmprabhu Aug 6, 2025
9dd2f28
fix: address comments
santhoshmprabhu Aug 7, 2025
f54bff7
chore: dockerfiles
santhoshmprabhu Aug 7, 2025
e5490a0
fix: address comments
santhoshmprabhu Aug 7, 2025
abf9d68
fix: add azure- prefix to block-iptables
santhoshmprabhu Aug 8, 2025
7ece36b
fix: rename subdir
santhoshmprabhu Aug 8, 2025
4c6a267
fix: import path
santhoshmprabhu Aug 8, 2025
131b33b
Update .github/workflows/golangci.yaml
santhoshmprabhu Aug 8, 2025
c267570
Update .github/workflows/golangci.yaml
santhoshmprabhu Aug 8, 2025
8e0fc82
Merge remote-tracking branch 'origin/master' into sanprabhu/rename-ip…
santhoshmprabhu Aug 8, 2025
308c97f
fix: remove redundant files
santhoshmprabhu Aug 8, 2025
17e4e18
fix: add code owner
santhoshmprabhu Aug 11, 2025
b933fcd
chore: dockerfiles
santhoshmprabhu Aug 11, 2025
d4dc0e7
chore: add more owners to bpf-prog
santhoshmprabhu Aug 12, 2025
d7eb4aa
chore:dockerfiles
santhoshmprabhu Aug 12, 2025
9339f73
Merge remote-tracking branch 'origin/sanprabhu/bpf-prog-owners' into …
santhoshmprabhu Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,33 @@ on:
types:
- checks_requested
jobs:
generate:
name: Generate BPF Handling Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run go generate
run: make bpf-lib && go generate ./...

- name: Upload generated code
uses: actions/upload-artifact@v4
with:
name: generated-bpf-program-code
path: ./bpf-prog/block-iptables/pkg/blockservice
golangci:
strategy:
fail-fast: false
matrix:
go-version: ['1.22.x', '1.23.x']
os: [ubuntu-latest, windows-latest]
name: Lint
needs: generate
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v5
Expand All @@ -26,6 +46,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download generated code
uses: actions/download-artifact@v4
with:
name: generated-bpf-program-code
path: ./bpf-prog/block-iptables/pkg/blockservice
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand Down
4 changes: 2 additions & 2 deletions .pipelines/build/dockerfiles/cns.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ ENTRYPOINT ["azure-cns.exe"]
EXPOSE 10090

# mcr.microsoft.com/azurelinux/base/core:3.0
FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/base/core@sha256:c09a4e011a092a45b5c46ac5633253eb1e1106df028912b89cbe225d9061ef0b AS build-helper
FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/base/core@sha256:e9bb4e5a79123f2ae29dc601f68adf63a636a455c4259423712b06b798cb201e AS build-helper
RUN tdnf install -y iptables

# mcr.microsoft.com/azurelinux/distroless/minimal:3.0
FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/distroless/minimal@sha256:c37100f358ee19e62c60673c54fb43b83d43b2c305846e44b23b2e032e9caf30 AS linux
FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/distroless/minimal@sha256:be0e4c34aaa7b369ff84907fa0a743f5d5904fa2d5b7da2e768ad8df285d4213 AS linux
ARG ARTIFACT_DIR .

COPY --from=build-helper /usr/sbin/*tables* /usr/sbin/
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ stages:
name: "$(BUILD_POOL_NAME_DEFAULT)"
steps:
- script: |
make ipv6-hp-bpf-lib
make bpf-lib
make all-binaries-platforms
name: "BuildAllPlatformBinaries"
displayName: "Build all platform binaries"
Expand Down
2 changes: 2 additions & 0 deletions .pipelines/templates/run-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ stages:
- script: |
set -e
make tools
make bpf-lib
go generate ./...

# run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml),
# stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to stdout, pipe to read from stdout then exit with that status code.
Expand Down
29 changes: 25 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ endif
# Interrogate the git repo and set some variables
REPO_ROOT ?= $(shell git rev-parse --show-toplevel)
REVISION ?= $(shell git rev-parse --short HEAD)
ACN_VERSION ?= $(shell git describe --exclude "azure-iptables-monitor*" --exclude "azure-ip-masq-merger*" --exclude "azure-ipam*" --exclude "dropgz*" --exclude "zapai*" --exclude "ipv6-hp-bpf*" --tags --always)
ACN_VERSION ?= $(shell git describe --exclude "azure-iptables-monitor*" --exclude "azure-ip-masq-merger*" --exclude "azure-ipam*" --exclude "dropgz*" --exclude "zapai*" --exclude "ipv6-hp-bpf*" --exclude "azure-block-iptables*" --tags --always)
IPV6_HP_BPF_VERSION ?= $(notdir $(shell git describe --match "ipv6-hp-bpf*" --tags --always))
AZURE_BLOCK_IPTABLES_VERSION ?= $(notdir $(shell git describe --match "azure-block-iptables*" --tags --always))
AZURE_IPAM_VERSION ?= $(notdir $(shell git describe --match "azure-ipam*" --tags --always))
AZURE_IP_MASQ_MERGER_VERSION ?= $(notdir $(shell git describe --match "azure-ip-masq-merger*" --tags --always))
AZURE_IPTABLES_MONITOR_VERSION ?= $(notdir $(shell git describe --match "azure-iptables-monitor*" --tags --always))
Expand All @@ -47,6 +48,7 @@ AZURE_IPAM_DIR = $(REPO_ROOT)/azure-ipam
AZURE_IP_MASQ_MERGER_DIR = $(REPO_ROOT)/azure-ip-masq-merger
AZURE_IPTABLES_MONITOR_DIR = $(REPO_ROOT)/azure-iptables-monitor
IPV6_HP_BPF_DIR = $(REPO_ROOT)/bpf-prog/ipv6-hp-bpf
AZURE_BLOCK_IPTABLES_DIR = $(REPO_ROOT)/bpf-prog/azure-block-iptables

CNI_NET_DIR = $(REPO_ROOT)/cni/network/plugin
CNI_IPAM_DIR = $(REPO_ROOT)/cni/ipam/plugin
Expand All @@ -62,6 +64,7 @@ AZURE_IPAM_BUILD_DIR = $(BUILD_DIR)/azure-ipam
AZURE_IP_MASQ_MERGER_BUILD_DIR = $(BUILD_DIR)/azure-ip-masq-merger
AZURE_IPTABLES_MONITOR_BUILD_DIR = $(BUILD_DIR)/azure-iptables-monitor
IPV6_HP_BPF_BUILD_DIR = $(BUILD_DIR)/bpf-prog/ipv6-hp-bpf
AZURE_BLOCK_IPTABLES_BUILD_DIR = $(BUILD_DIR)/bpf-prog/azure-block-iptables
IMAGE_DIR = $(OUTPUT_DIR)/images

CNI_BUILD_DIR = $(BUILD_DIR)/cni
Expand Down Expand Up @@ -111,6 +114,7 @@ AZURE_IPAM_ARCHIVE_NAME = azure-ipam-$(GOOS)-$(GOARCH)-$(AZURE_IPAM_VERSION).$(A
AZURE_IP_MASQ_MERGER_ARCHIVE_NAME = azure-ip-masq-merger-$(GOOS)-$(GOARCH)-$(AZURE_IP_MASQ_MERGER_VERSION).$(ARCHIVE_EXT)
AZURE_IPTABLES_MONITOR_ARCHIVE_NAME = azure-iptables-monitor-$(GOOS)-$(GOARCH)-$(AZURE_IPTABLES_MONITOR_VERSION).$(ARCHIVE_EXT)
IPV6_HP_BPF_ARCHIVE_NAME = ipv6-hp-bpf-$(GOOS)-$(GOARCH)-$(IPV6_HP_BPF_VERSION).$(ARCHIVE_EXT)
AZURE_BLOCK_IPTABLES_ARCHIVE_NAME = azure-block-iptables-$(GOOS)-$(GOARCH)-$(AZURE_BLOCK_IPTABLES_VERSION).$(ARCHIVE_EXT)

# Image info file names.
CNI_IMAGE_INFO_FILE = azure-cni-$(CNI_VERSION).txt
Expand All @@ -127,7 +131,7 @@ all-binaries-platforms: ## Make all platform binaries

# OS specific binaries/images
ifeq ($(GOOS),linux)
all-binaries: acncli azure-cni-plugin azure-cns azure-npm azure-ipam azure-ip-masq-merger azure-iptables-monitor ipv6-hp-bpf
all-binaries: acncli azure-cni-plugin azure-cns azure-npm azure-ipam azure-ip-masq-merger azure-iptables-monitor ipv6-hp-bpf azure-block-iptables
all-images: npm-image cns-image cni-manager-image azure-ip-masq-merger-image azure-iptables-monitor-image ipv6-hp-bpf-image
else
all-binaries: azure-cni-plugin azure-cns azure-npm
Expand All @@ -142,6 +146,7 @@ acncli: acncli-binary acncli-archive
azure-npm: azure-npm-binary npm-archive
azure-ipam: azure-ipam-binary azure-ipam-archive
ipv6-hp-bpf: ipv6-hp-bpf-binary ipv6-hp-bpf-archive
azure-block-iptables: azure-block-iptables-binary azure-block-iptables-archive
azure-ip-masq-merger: azure-ip-masq-merger-binary azure-ip-masq-merger-archive
azure-iptables-monitor: azure-iptables-monitor-binary azure-iptables-monitor-archive

Expand All @@ -168,6 +173,9 @@ azure-iptables-monitor-version: ## prints the azure-iptables-monitor version
ipv6-hp-bpf-version: ## prints the ipv6-hp-bpf version
@echo $(IPV6_HP_BPF_VERSION)

azure-block-iptables-version: ## prints the azure-block-iptables version
@echo $(AZURE_BLOCK_IPTABLES_VERSION)

cni-version: ## prints the cni version
@echo $(CNI_VERSION)

Expand All @@ -191,8 +199,8 @@ ipv6-hp-bpf-binary:
cd $(IPV6_HP_BPF_DIR) && CGO_ENABLED=0 go generate ./...
cd $(IPV6_HP_BPF_DIR)/cmd/ipv6-hp-bpf && CGO_ENABLED=0 go build -v -o $(IPV6_HP_BPF_BUILD_DIR)/ipv6-hp-bpf$(EXE_EXT) -ldflags "-X main.version=$(IPV6_HP_BPF_VERSION)" -gcflags="-dwarflocationlists=true"

# Libraries for ipv6-hp-bpf
ipv6-hp-bpf-lib:
# Libraries for bpf
bpf-lib:
ifeq ($(GOARCH),amd64)
sudo apt-get update && sudo apt-get install -y llvm clang linux-libc-dev linux-headers-generic libbpf-dev libc6-dev nftables iproute2 gcc-multilib
for dir in /usr/include/x86_64-linux-gnu/*; do sudo ln -sfn "$$dir" /usr/include/$$(basename "$$dir"); done
Expand All @@ -201,6 +209,11 @@ else ifeq ($(GOARCH),arm64)
for dir in /usr/include/aarch64-linux-gnu/*; do sudo ln -sfn "$$dir" /usr/include/$$(basename "$$dir"); done
endif

# Build the azure-block-iptables binary.
azure-block-iptables-binary:
cd $(AZURE_BLOCK_IPTABLES_DIR) && CGO_ENABLED=0 go generate ./...
cd $(AZURE_BLOCK_IPTABLES_DIR)/cmd/azure-block-iptables && CGO_ENABLED=0 go build -v -o $(AZURE_BLOCK_IPTABLES_BUILD_DIR)/azure-block-iptables$(EXE_EXT) -ldflags "-X main.version=$(AZURE_BLOCK_IPTABLES_VERSION)" -gcflags="-dwarflocationlists=true"

# Build the Azure CNI network binary.
azure-vnet-binary:
cd $(CNI_NET_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet$(EXE_EXT) -ldflags "-X main.version=$(CNI_VERSION)" -gcflags="-dwarflocationlists=true"
Expand Down Expand Up @@ -847,6 +860,14 @@ ifeq ($(GOOS),linux)
cd $(IPV6_HP_BPF_BUILD_DIR) && $(ARCHIVE_CMD) $(IPV6_HP_BPF_ARCHIVE_NAME) ipv6-hp-bpf$(EXE_EXT)
endif

# Create a azure-block-iptables archive for the target platform.
.PHONY: azure-block-iptables-archive
azure-block-iptables-archive: azure-block-iptables-binary
ifeq ($(GOOS),linux)
$(MKDIR) $(AZURE_BLOCK_IPTABLES_BUILD_DIR)
cd $(AZURE_BLOCK_IPTABLES_BUILD_DIR) && $(ARCHIVE_CMD) $(AZURE_BLOCK_IPTABLES_ARCHIVE_NAME) azure-block-iptables$(EXE_EXT)
endif

##@ Utils

clean: ## Clean build artifacts.
Expand Down
Loading
Loading