Skip to content

Commit

Permalink
Interface autodetection - ebpf (projectcalico#8803)
Browse files Browse the repository at this point in the history
  • Loading branch information
sridhartigera authored May 30, 2024
1 parent 7e5c4dd commit dfa5f61
Show file tree
Hide file tree
Showing 13 changed files with 497 additions and 69 deletions.
2 changes: 1 addition & 1 deletion api/pkg/lib/numorstring/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (p Protocol) NumValue() (uint8, error) {
return (Uint8OrString)(p).NumValue()
}

// SupportsPorts returns whether this protocol supports ports. This returns true if
// SupportsProtocols returns whether this protocol supports ports. This returns true if
// the numerical or string version of the protocol indicates TCP (6), UDP (17), or SCTP (132).
func (p Protocol) SupportsPorts() bool {
num, err := p.NumValue()
Expand Down
1 change: 1 addition & 0 deletions apiserver/cmd/apiserver/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func logrusLevel() logrus.Level {
return logrus.ErrorLevel
}

// NewCommandStartMaster provides a CLI handler for 'start master' command
func NewCommandStartCalicoServer(out io.Writer) (*cobra.Command, error) {
// o := NewCalicoServerOptions(out, errOut)

Expand Down
2 changes: 1 addition & 1 deletion apiserver/pkg/storage/calico/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func CreateClientFromConfig() clientv3.Interface {
return c
}

// Versioner returns the versioner associated with this interface
// Versioned returns the versioned associated with this interface
func (rs *resourceStore) Versioner() storage.Versioner {
return rs.versioner
}
Expand Down
3 changes: 1 addition & 2 deletions felix/bpf-gpl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,11 @@ bin:

%.d: %.c
set -e; rm -f $@; \
$(CC) -M -MT $(subst .c,.o,$<) -I. $(CFLAGS) $< > $@.$$$$ || { rm -f $@.$$$$; false; } ; \
$(CC) -M $(CFLAGS) $< > $@.$$$$ || { rm -f $@.$$$$; false; } ; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$

D_FILES=$(C_FILES:.c=.d)
D_FILES+=$(UT_C_FILES:.c=.d)

ifneq ($(MAKECMDGOALS),clean)
include $(D_FILES)
Expand Down
16 changes: 15 additions & 1 deletion felix/bpf/ifstate/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,27 @@ const (
FlgWEP = uint32(0x1)
FlgIPv4Ready = uint32(0x2)
FlgIPv6Ready = uint32(0x4)
FlgMax = uint32(0x7)
FlgHEP = uint32(0x8)
FlgBond = uint32(0x10)
FlgBondSlave = uint32(0x20)
FlgVxlan = uint32(0x40)
FlgIPIP = uint32(0x80)
FlgWireguard = uint32(0x100)
FlgL3 = uint32(0x200)
FlgMax = uint32(0x3ff)
)

var flagsToStr = map[uint32]string{
FlgWEP: "workload",
FlgIPv4Ready: "v4Ready",
FlgIPv6Ready: "v6Ready",
FlgHEP: "host",
FlgBond: "bond",
FlgBondSlave: "bondslave",
FlgVxlan: "vxlan",
FlgIPIP: "ipip",
FlgWireguard: "wg",
FlgL3: "l3",
}

var MapParams = maps.MapParameters{
Expand Down
4 changes: 2 additions & 2 deletions felix/bpf/ut/attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func runAttachTest(t *testing.T, ipv6Enabled bool) {
}

hostep1State = ifstateMap[ifstate.NewKey(uint32(host1.Attrs().Index))]
Expect(hostep1State.Flags()).To(Equal(ifstate.FlgIPv4Ready))
Expect(hostep1State.Flags()).To(Equal(ifstate.FlgIPv4Ready | ifstate.FlgHEP))

if ipv6Enabled {
// IPv6 address update
Expand Down Expand Up @@ -216,7 +216,7 @@ func runAttachTest(t *testing.T, ipv6Enabled bool) {
Expect(hostep1State.IngressPolicyV6()).NotTo(Equal(-1))
Expect(hostep1State.EgressPolicyV6()).NotTo(Equal(-1))
Expect(hostep1State.XDPPolicyV6()).NotTo(Equal(-1))
Expect(hostep1State.Flags()).To(Equal(ifstate.FlgIPv4Ready | ifstate.FlgIPv6Ready))
Expect(hostep1State.Flags()).To(Equal(ifstate.FlgIPv4Ready | ifstate.FlgIPv6Ready | ifstate.FlgHEP))
Expect(ifstateMap).To(HaveKey(ifstate.NewKey(uint32(workload0.Attrs().Index))))
workloadep0State := ifstateMap[ifstate.NewKey(uint32(workload0.Attrs().Index))]
Expect(workloadep0State.Flags()).To(Equal(ifstate.FlgWEP | ifstate.FlgIPv4Ready | ifstate.FlgIPv6Ready))
Expand Down
2 changes: 1 addition & 1 deletion felix/config/config_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type Config struct {
BPFLogLevel string `config:"oneof(off,info,debug);off;non-zero"`
BPFLogFilters map[string]string `config:"keyvaluelist;;"`
BPFCTLBLogFilter string `config:"oneof(all);;"`
BPFDataIfacePattern *regexp.Regexp `config:"regexp;^((en|wl|ww|sl|ib)[Popsx].*|(eth|wlan|wwan).*|tunl0$|vxlan.calico$|vxlan-v6.calico$|wireguard.cali$|wg-v6.cali$)"`
BPFDataIfacePattern *regexp.Regexp `config:"regexp;^((en|wl|ww|sl|ib)[Popsx].*|(eth|wlan|wwan|bond).*|tunl0$|vxlan.calico$|vxlan-v6.calico$|wireguard.cali$|wg-v6.cali$)"`
BPFL3IfacePattern *regexp.Regexp `config:"regexp;"`
BPFConnectTimeLoadBalancingEnabled bool `config:"bool;;"`
BPFConnectTimeLoadBalancing string `config:"oneof(TCP,Enabled,Disabled);TCP;non-zero"`
Expand Down
Loading

0 comments on commit dfa5f61

Please sign in to comment.