Skip to content

Commit

Permalink
rename dummy device
Browse files Browse the repository at this point in the history
Signed-off-by: walnuts1018 <[email protected]>
  • Loading branch information
walnuts1018 committed Aug 27, 2024
1 parent 2040975 commit 90f4c9f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions config/samples/nat-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ spec:
- name: nat-client
image: ghcr.io/cybozu/ubuntu-debug:22.04
command: ["sleep"]
securityContext:
privileged: true
args:
- infinity
3 changes: 2 additions & 1 deletion dockerfiles/Dockerfile.egress-controller
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ COPY cmd/egress-controller/main.go cmd/egress-controller/main.go
COPY api/ api/
COPY internal/ internal/

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o egress-controller cmd/egress-controller/main.go
RUN --mount=type=cache,target=/go/pkg/mod/ \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o egress-controller cmd/egress-controller/main.go

FROM ghcr.io/cybozu/ubuntu:22.04
WORKDIR /
Expand Down
7 changes: 5 additions & 2 deletions dockerfiles/Dockerfile.nat-gateway
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ COPY cmd/nat-gateway/main.go cmd/nat-gateway/main.go
COPY api/ api/
COPY internal/ internal/

RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o nat-gateway cmd/nat-gateway/main.go
RUN --mount=type=cache,target=/go/pkg/mod/ \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o nat-gateway cmd/nat-gateway/main.go

FROM ghcr.io/cybozu/ubuntu:22.04
WORKDIR /
RUN apt-get -yy update && apt-get install -yy netbase kmod iptables iproute2
RUN --mount=type=cache,target=/var/lib/apt,sharing=locked \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get -yy update && apt-get install -yy netbase kmod iptables iproute2

COPY --from=builder /workspace/nat-gateway .
USER 0:0
Expand Down
5 changes: 4 additions & 1 deletion internal/fou/fou.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ func (t *FouTunnelController) Init() error {

attrs := netlink.NewLinkAttrs()
attrs.Name = fouDummy
return netlink.LinkAdd(&netlink.Dummy{LinkAttrs: attrs})

if err := netlink.LinkAdd(&netlink.Dummy{LinkAttrs: attrs}); err != nil {
return fmt.Errorf("failed to add dummy device: %w", err)
}
return nil
}

func (t *FouTunnelController) initIPTables(p iptables.Protocol) error {
Expand Down
8 changes: 6 additions & 2 deletions internal/nat/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
egressProtocolID = 30
egressRulePrio = 2000

egressDummy = "pona-egress-dummy"
egressDummy = "nat-dummy"
)

type Controller interface {
Expand Down Expand Up @@ -100,7 +100,11 @@ func (c *controller) Init() error {

attrs := netlink.NewLinkAttrs()
attrs.Name = egressDummy
return netlink.LinkAdd(&netlink.Dummy{LinkAttrs: attrs})

if err := netlink.LinkAdd(&netlink.Dummy{LinkAttrs: attrs}); err != nil {
return fmt.Errorf("failed to add dummy device: %w", err)
}
return nil
}

func (c *controller) AddClient(addr netip.Addr, link netlink.Link) error {
Expand Down

0 comments on commit 90f4c9f

Please sign in to comment.