Skip to content

Commit

Permalink
Merge pull request #1947 from thomasferrandiz/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
thomasferrandiz authored Apr 23, 2024
2 parents 7c210a6 + 5c96864 commit 66b7dc3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,8 @@ func ReadIP6CIDRsFromSubnetFile(path string, CIDRKey string) []ip.IP6Net {

func newTrafficManager(useNftables bool) trafficmngr.TrafficManager {
if useNftables {
log.Info("Starting flannel in nftables mode")
return &nftables.NFTablesManager{}
} else {
log.Info("Starting flannel in iptables mode")
return &iptables.IPTablesManager{}

}
}
6 changes: 4 additions & 2 deletions pkg/trafficmngr/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type IPTablesManager struct {
}

func (iptm *IPTablesManager) Init(ctx context.Context, wg *sync.WaitGroup) error {
log.Info("Starting flannel in iptables mode...")

iptm.ipv4Rules = make([]trafficmngr.IPTablesRule, 0, 10)
iptm.ipv6Rules = make([]trafficmngr.IPTablesRule, 0, 10)
wg.Add(1)
Expand Down Expand Up @@ -109,7 +111,7 @@ func (iptm *IPTablesManager) SetupAndEnsureMasqRules(ctx context.Context, flanne

if !flannelIPv4Net.Empty() {
// recycle iptables rules only when network configured or subnet leased is not equal to current one.
if prevNetwork != flannelIPv4Net && prevSubnet != currentlease.Subnet {
if !(flannelIPv4Net.Equal(prevNetwork) && prevSubnet.Equal(currentlease.Subnet)) {
log.Infof("Current network or subnet (%v, %v) is not equal to previous one (%v, %v), trying to recycle old iptables rules",
flannelIPv4Net, currentlease.Subnet, prevNetwork, prevSubnet)
newLease := &lease.Lease{
Expand All @@ -126,7 +128,7 @@ func (iptm *IPTablesManager) SetupAndEnsureMasqRules(ctx context.Context, flanne
}
if !flannelIPv6Net.Empty() {
// recycle iptables rules only when network configured or subnet leased is not equal to current one.
if prevIPv6Network != flannelIPv6Net && prevIPv6Subnet != currentlease.IPv6Subnet {
if !(flannelIPv6Net.Equal(prevIPv6Network) && prevIPv6Subnet.Equal(currentlease.IPv6Subnet)) {
log.Infof("Current network or subnet (%v, %v) is not equal to previous one (%v, %v), trying to recycle old iptables rules",
flannelIPv6Net, currentlease.IPv6Subnet, prevIPv6Network, prevIPv6Subnet)
newLease := &lease.Lease{
Expand Down
2 changes: 1 addition & 1 deletion pkg/trafficmngr/iptables/iptables_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (iptr *ipTablesRestore) runWithOutput(args []string, stdin io.Reader) (stri
cmd.Stdin = stdin

if err := cmd.Run(); err != nil {
return "", "", err
return stdout.String(), stderr.String(), err
}

return stdout.String(), stderr.String(), nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/trafficmngr/iptables/iptables_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type IPTables interface {
}

func (iptm IPTablesManager) Init(ctx context.Context, wg *sync.WaitGroup) error {
log.Warning(trafficmngr.ErrUnimplemented)
log.Info("Starting flannel in windows mode...")
return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/trafficmngr/nftables/nftables.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type NFTablesManager struct {
}

func (nftm *NFTablesManager) Init(ctx context.Context, wg *sync.WaitGroup) error {
log.Info("Starting flannel in nftables mode...")
var err error
nftm.nftv4, err = initTable(ctx, knftables.IPv4Family, ipv4Table)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/trafficmngr/nftables/nftables_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type NFTablesManager struct {
}

func (nftm *NFTablesManager) Init(ctx context.Context, wg *sync.WaitGroup) error {
log.Warning(trafficmngr.ErrUnimplemented)
log.Info("Starting flannel in windows mode...")
return nil
}

Expand Down

0 comments on commit 66b7dc3

Please sign in to comment.