Skip to content

Commit

Permalink
fix infinity recursion in Equal while findrules
Browse files Browse the repository at this point in the history
  • Loading branch information
singchia committed Feb 18, 2024
1 parent bf53b93 commit 9b675dd
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
5 changes: 4 additions & 1 deletion ebtables/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ func (bm *baseMatch) Parse(params []byte) (int, bool) {
}

func (bm *baseMatch) Equal(mth Match) bool {
return bm.Short() == mth.Short()
if bm.child != nil {
return bm.child.Short() == mth.Short()
}
return false
}

func (bm *baseMatch) Depends() []MatchType {
Expand Down
5 changes: 4 additions & 1 deletion ebtables/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ func (bo *baseOption) LongArgs() []string {
}

func (bo *baseOption) Equal(opt Option) bool {
return bo.Short() == opt.Short()
if bo.child != nil {
return bo.child.Short() == opt.Short()
}
return false
}

// Use a file lock to support concurrent scripts updating the
Expand Down
5 changes: 4 additions & 1 deletion ebtables/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ func (bt *baseTarget) Parse([]byte) (int, bool) {
}

func (bt *baseTarget) Equal(tgt Target) bool {
return bt.Short() == tgt.Short()
if bt.child != nil {
return bt.child.Short() == tgt.Short()
}
return false
}

type TargetEmpty struct {
Expand Down
5 changes: 4 additions & 1 deletion ebtables/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ func (bw *baseWatcher) LongArgs() []string {
}

func (bw *baseWatcher) Equal(wth Watcher) bool {
return bw.Short() == wth.Short()
if bw.child != nil {
return bw.child.Short() == wth.Short()
}
return false
}

type OptionWatcherLog func(*WatcherLog)
Expand Down
5 changes: 4 additions & 1 deletion iptables/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ func (bm *baseMatch) Depends() []MatchType {
}

func (bm *baseMatch) Equal(mth Match) bool {
return bm.Short() == mth.Short()
if bm.child != nil {
return bm.child.Short() == mth.Short()
}
return false
}

type MatchIPv4 struct {
Expand Down
5 changes: 4 additions & 1 deletion iptables/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ func (bo *baseOption) LongArgs() []string {
}

func (bo *baseOption) Equal(opt Option) bool {
return bo.Short() == opt.Short()
if bo.child != nil {
return bo.child.Short() == opt.Short()
}
return false
}

type OptionFragment struct {
Expand Down
5 changes: 4 additions & 1 deletion iptables/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ func (bt *baseTarget) Parse([]byte) (int, bool) {
}

func (bt *baseTarget) Equal(tgt Target) bool {
return bt.Short() == tgt.Short()
if bt.child != nil {
return bt.child.Short() == tgt.Short()
}
return false
}

type TargetEmpty struct {
Expand Down

0 comments on commit 9b675dd

Please sign in to comment.