Skip to content

Commit

Permalink
Merge pull request #830 from rollandf/ovs-internal
Browse files Browse the repository at this point in the history
ovs: add internal interface
  • Loading branch information
zeeke authored Jan 13, 2025
2 parents 0860d53 + 84d0a6d commit f891498
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
9 changes: 9 additions & 0 deletions pkg/host/internal/bridge/ovs/ovs.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ func (o *ovs) CreateOVSBridge(ctx context.Context, conf *sriovnetworkv1.OVSConfi
funcLog.Error(err, "CreateOVSBridge(): failed to get bridge after creation")
return err
}
funcLog.V(2).Info("CreateOVSBridge(): add internal interface to the bridge")
if err := o.addInterface(ctx, dbClient, bridge, &InterfaceEntry{
Name: bridge.Name,
UUID: uuid.NewString(),
Type: "internal",
}); err != nil {
funcLog.Error(err, "CreateOVSBridge(): failed to add internal interface to the bridge")
return err
}
funcLog.V(2).Info("CreateOVSBridge(): add uplink interface to the bridge")
if err := o.addInterface(ctx, dbClient, bridge, &InterfaceEntry{
Name: conf.Uplinks[0].Name,
Expand Down
29 changes: 23 additions & 6 deletions pkg/host/internal/bridge/ovs/ovs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,43 @@ func createInitialDBContent(ctx context.Context, c client.Client, expectedState
func validateDBConfig(dbContent *testDBEntries, conf *sriovnetworkv1.OVSConfigExt) {
Expect(dbContent.OpenVSwitch).To(HaveLen(1))
Expect(dbContent.Bridge).To(HaveLen(1))
Expect(dbContent.Interface).To(HaveLen(1))
Expect(dbContent.Port).To(HaveLen(1))
Expect(dbContent.Interface).To(HaveLen(2))
Expect(dbContent.Port).To(HaveLen(2))
ovs := dbContent.OpenVSwitch[0]
br := dbContent.Bridge[0]
port := dbContent.Port[0]
iface := dbContent.Interface[0]
ports := make(map[string]*PortEntry, 0)
interfaces := make(map[string]*InterfaceEntry, 0)
for _, p := range dbContent.Port {
ports[p.Name] = p
}
for _, ifc := range dbContent.Interface {
interfaces[ifc.Name] = ifc
}
Expect(ovs.Bridges).To(ContainElement(br.UUID))
Expect(br.Name).To(Equal(conf.Name))
Expect(br.DatapathType).To(Equal(conf.Bridge.DatapathType))
Expect(br.OtherConfig).To(Equal(conf.Bridge.OtherConfig))
Expect(br.ExternalIDs).To(Equal(conf.Bridge.ExternalIDs))
port, ok := ports[conf.Uplinks[0].Name]
Expect(ok).To(BeTrue())
Expect(br.Ports).To(ContainElement(port.UUID))
Expect(port.Name).To(Equal(conf.Uplinks[0].Name))
iface, ok := interfaces[conf.Uplinks[0].Name]
Expect(ok).To(BeTrue())
Expect(port.Interfaces).To(ContainElement(iface.UUID))
Expect(iface.Name).To(Equal(conf.Uplinks[0].Name))
Expect(iface.Options).To(Equal(conf.Uplinks[0].Interface.Options))
Expect(iface.Type).To(Equal(conf.Uplinks[0].Interface.Type))
Expect(iface.OtherConfig).To(Equal(conf.Uplinks[0].Interface.OtherConfig))
Expect(iface.ExternalIDs).To(Equal(conf.Uplinks[0].Interface.ExternalIDs))
Expect(iface.MTURequest).To(Equal(conf.Uplinks[0].Interface.MTURequest))
internalPort, ok := ports[conf.Name]
Expect(ok).To(BeTrue())
internalIface, ok := interfaces[conf.Name]
Expect(ok).To(BeTrue())
Expect(internalPort.Interfaces).To(ContainElement(internalIface.UUID))
Expect(internalIface.Options).To(BeNil())
Expect(internalIface.Type).To(Equal("internal"))
Expect(internalIface.OtherConfig).To(BeNil())
Expect(internalIface.ExternalIDs).To(BeNil())
}

var _ = Describe("OVS", func() {
Expand Down

0 comments on commit f891498

Please sign in to comment.