Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes #1947

Merged
merged 3 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,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)) {
thomasferrandiz marked this conversation as resolved.
Show resolved Hide resolved
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)) {
thomasferrandiz marked this conversation as resolved.
Show resolved Hide resolved
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
Loading