Skip to content

Commit

Permalink
fix(tap): tap app now takes into account subnet specified by user
Browse files Browse the repository at this point in the history
  • Loading branch information
activeshadow committed Sep 29, 2023
1 parent 6e897cd commit 8c938fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/go/app/tap.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ func (this *Tap) PostStart(ctx context.Context, exp *types.Experiment) error {
return fmt.Errorf("tap already created for VLAN %s", t.VLAN)
}

t.Init(tap.Experiment(exp.Metadata.Name), tap.UsedPairs(pairs))
opts := []tap.Option{tap.Experiment(exp.Metadata.Name), tap.UsedPairs(pairs)}

if subnet, err := netaddr.ParseIPPrefix(t.Subnet); err == nil {
opts = append(opts, tap.PairSubnet(subnet))
}

t.Init(opts...)

// Tap name is random, yet descriptive to the fact that it's a "tapapp" tap.
t.Name = fmt.Sprintf("%s-tapapp", util.RandomString(8))
Expand Down
9 changes: 5 additions & 4 deletions src/go/util/tap/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ type options struct {
}

func NewOptions(opts ...Option) options {
o := options{
netns: true,
subnet: netaddr.MustParseIPPrefix("10.213.47.0/30"),
}
o := options{netns: true}

for _, opt := range opts {
opt(&o)
}

if o.subnet.IsZero() {
o.subnet = netaddr.MustParseIPPrefix("10.213.47.0/30")
}

return o
}

Expand Down

0 comments on commit 8c938fb

Please sign in to comment.