Skip to content

Commit

Permalink
s/ isSource->ipsSource
Browse files Browse the repository at this point in the history
  • Loading branch information
jayunit100 committed Oct 21, 2019
1 parent ceef402 commit 41ac785
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions dataplane/linux/xdp_state.go
Expand Up @@ -158,7 +158,7 @@ func (x *xdpState) ProcessPendingDiffState(epSourceV4 endpointsSource) {
}
}

func (x *xdpState) ResyncIfNeeded(isSourceV4 ipsetsSource) error {
func (x *xdpState) ResyncIfNeeded(ipsSourceV4 ipsetsSource) error {
var err error
if !x.common.needResync {
return nil
Expand All @@ -170,7 +170,7 @@ func (x *xdpState) ResyncIfNeeded(isSourceV4 ipsetsSource) error {
log.Info("Retrying after an XDP update failure...")
}
log.Info("Resyncing XDP state with dataplane.")
err = x.tryResync(newConvertingIPSetsSource(isSourceV4))
err = x.tryResync(newConvertingIPSetsSource(ipsSourceV4))
if err == nil {
success = true
break
Expand All @@ -183,10 +183,10 @@ func (x *xdpState) ResyncIfNeeded(isSourceV4 ipsetsSource) error {
return nil
}

func (x *xdpState) ApplyBPFActions(isSource ipsetsSource) error {
func (x *xdpState) ApplyBPFActions(ipsSource ipsetsSource) error {
if x.ipV4State != nil {
memberCacheV4 := newXDPMemberCache(x.ipV4State.getBpfIPFamily(), x.common.bpfLib)
err := x.ipV4State.bpfActions.apply(memberCacheV4, x.ipV4State.ipsetIDsToMembers, newConvertingIPSetsSource(isSource), x.common.xdpModes)
err := x.ipV4State.bpfActions.apply(memberCacheV4, x.ipV4State.ipsetIDsToMembers, newConvertingIPSetsSource(ipsSource), x.common.xdpModes)
x.ipV4State.bpfActions = newXDPBPFActions()
if err != nil {
log.WithError(err).Info("Applying BPF actions did not succeed. Queueing XDP resync.")
Expand Down Expand Up @@ -235,18 +235,18 @@ func (x *xdpState) WipeXDP() error {
// because we are about to drop everything, and when
// we only drop stuff, the code does not call
// ipsetsSource functions at all.
isSource := &nilIPSetsSource{}
if err := x.tryResync(isSource); err != nil {
ipsSource := &nilIPSetsSource{}
if err := x.tryResync(ipsSource); err != nil {
return err
}
if err := x.ApplyBPFActions(isSource); err != nil {
if err := x.ApplyBPFActions(ipsSource); err != nil {
return err
}
x.QueueResync()
return nil
}

func (x *xdpState) tryResync(isSourceV4 ipsetsSource) error {
func (x *xdpState) tryResync(ipsSourceV4 ipsetsSource) error {
if x.common.programTag == "" {
tag, err := x.common.bpfLib.GetXDPObjTagAuto()
if err != nil {
Expand All @@ -255,7 +255,7 @@ func (x *xdpState) tryResync(isSourceV4 ipsetsSource) error {
x.common.programTag = tag
}
if x.ipV4State != nil {
if err := x.ipV4State.tryResync(&x.common, isSourceV4); err != nil {
if err := x.ipV4State.tryResync(&x.common, ipsSourceV4); err != nil {
return err
}
}
Expand Down Expand Up @@ -428,7 +428,7 @@ func (s *xdpIPState) getBpfIPFamily() bpf.IPFamily {
}

// newXDPResyncState creates the xdpResyncState object which represents the
func (s *xdpIPState) newXDPResyncState(bpfLib bpf.BPFDataplane, isSource ipsetsSource, programTag string, xpdModes []bpf.XDPMode) (*xdpResyncState, error) {
func (s *xdpIPState) newXDPResyncState(bpfLib bpf.BPFDataplane, ipsSource ipsetsSource, programTag string, xpdModes []bpf.XDPMode) (*xdpResyncState, error) {
xdpIfaces, err := bpfLib.GetXDPIfaces()
if err != nil {
return nil, err
Expand Down Expand Up @@ -508,7 +508,7 @@ func (s *xdpIPState) newXDPResyncState(bpfLib bpf.BPFDataplane, isSource ipsetsS
if visited.Contains(setID) {
return nil
}
members, err := s.getIPSetMembers(setID, isSource)
members, err := s.getIPSetMembers(setID, ipsSource)
if err != nil {
opErr = err
return set.StopIteration
Expand Down Expand Up @@ -542,8 +542,8 @@ func isValidMode(mode bpf.XDPMode, xdpModes []bpf.XDPMode) bool {
return false
}

func (s *xdpIPState) getIPSetMembers(setID string, isSource ipsetsSource) (set.Set, error) {
return getIPSetMembers(s.ipsetIDsToMembers, setID, isSource)
func (s *xdpIPState) getIPSetMembers(setID string, ipsSource ipsetsSource) (set.Set, error) {
return getIPSetMembers(s.ipsetIDsToMembers, setID, ipsSource)
}

// tryResync performs reconciles global XDP state with the by using input ipSets
Expand Down Expand Up @@ -1753,7 +1753,7 @@ func newXDPBPFActions() *xdpBPFActions {
// installs XDP programs, creates and removes BPF maps, adds and
// removes whole ipsets into/from the BPF maps, adds and removes
// certain members to/from BPF maps.
func (a *xdpBPFActions) apply(memberCache *xdpMemberCache, ipsetIDsToMembers *ipsetIDsToMembers, isSource ipsetsSource, xdpModes []bpf.XDPMode) error {
func (a *xdpBPFActions) apply(memberCache *xdpMemberCache, ipsetIDsToMembers *ipsetIDsToMembers, ipsSource ipsetsSource, xdpModes []bpf.XDPMode) error {
var opErr error
logCxt := log.WithField("family", memberCache.GetFamily().String())

Expand Down Expand Up @@ -1827,7 +1827,7 @@ func (a *xdpBPFActions) apply(memberCache *xdpMemberCache, ipsetIDsToMembers *ip
"setID": setID,
"refCount": refCount,
}).Debug("Adding members of ipset to BPF blacklist map.")
members, err := getIPSetMembers(ipsetIDsToMembers, setID, isSource)
members, err := getIPSetMembers(ipsetIDsToMembers, setID, ipsSource)
if err != nil {
return err
}
Expand Down Expand Up @@ -1913,13 +1913,13 @@ func getXDPModes(allowGenericXDP bool) []bpf.XDPMode {
return modes
}

func getIPSetMembers(ipsetIDsToMembers *ipsetIDsToMembers, setID string, isSource ipsetsSource) (set.Set, error) {
func getIPSetMembers(ipsetIDsToMembers *ipsetIDsToMembers, setID string, ipsSource ipsetsSource) (set.Set, error) {
members, ok := ipsetIDsToMembers.GetCached(setID)
if ok {
return members, nil
}

members, err := isSource.GetIPSetMembers(setID)
members, err := ipsSource.GetIPSetMembers(setID)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 41ac785

Please sign in to comment.