Skip to content

Commit f891498

Browse files
authored
Merge pull request #830 from rollandf/ovs-internal
ovs: add internal interface
2 parents 0860d53 + 84d0a6d commit f891498

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

pkg/host/internal/bridge/ovs/ovs.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ func (o *ovs) CreateOVSBridge(ctx context.Context, conf *sriovnetworkv1.OVSConfi
148148
funcLog.Error(err, "CreateOVSBridge(): failed to get bridge after creation")
149149
return err
150150
}
151+
funcLog.V(2).Info("CreateOVSBridge(): add internal interface to the bridge")
152+
if err := o.addInterface(ctx, dbClient, bridge, &InterfaceEntry{
153+
Name: bridge.Name,
154+
UUID: uuid.NewString(),
155+
Type: "internal",
156+
}); err != nil {
157+
funcLog.Error(err, "CreateOVSBridge(): failed to add internal interface to the bridge")
158+
return err
159+
}
151160
funcLog.V(2).Info("CreateOVSBridge(): add uplink interface to the bridge")
152161
if err := o.addInterface(ctx, dbClient, bridge, &InterfaceEntry{
153162
Name: conf.Uplinks[0].Name,

pkg/host/internal/bridge/ovs/ovs_test.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,43 @@ func createInitialDBContent(ctx context.Context, c client.Client, expectedState
141141
func validateDBConfig(dbContent *testDBEntries, conf *sriovnetworkv1.OVSConfigExt) {
142142
Expect(dbContent.OpenVSwitch).To(HaveLen(1))
143143
Expect(dbContent.Bridge).To(HaveLen(1))
144-
Expect(dbContent.Interface).To(HaveLen(1))
145-
Expect(dbContent.Port).To(HaveLen(1))
144+
Expect(dbContent.Interface).To(HaveLen(2))
145+
Expect(dbContent.Port).To(HaveLen(2))
146146
ovs := dbContent.OpenVSwitch[0]
147147
br := dbContent.Bridge[0]
148-
port := dbContent.Port[0]
149-
iface := dbContent.Interface[0]
148+
ports := make(map[string]*PortEntry, 0)
149+
interfaces := make(map[string]*InterfaceEntry, 0)
150+
for _, p := range dbContent.Port {
151+
ports[p.Name] = p
152+
}
153+
for _, ifc := range dbContent.Interface {
154+
interfaces[ifc.Name] = ifc
155+
}
150156
Expect(ovs.Bridges).To(ContainElement(br.UUID))
151157
Expect(br.Name).To(Equal(conf.Name))
152158
Expect(br.DatapathType).To(Equal(conf.Bridge.DatapathType))
153159
Expect(br.OtherConfig).To(Equal(conf.Bridge.OtherConfig))
154160
Expect(br.ExternalIDs).To(Equal(conf.Bridge.ExternalIDs))
161+
port, ok := ports[conf.Uplinks[0].Name]
162+
Expect(ok).To(BeTrue())
155163
Expect(br.Ports).To(ContainElement(port.UUID))
156-
Expect(port.Name).To(Equal(conf.Uplinks[0].Name))
164+
iface, ok := interfaces[conf.Uplinks[0].Name]
165+
Expect(ok).To(BeTrue())
157166
Expect(port.Interfaces).To(ContainElement(iface.UUID))
158-
Expect(iface.Name).To(Equal(conf.Uplinks[0].Name))
159167
Expect(iface.Options).To(Equal(conf.Uplinks[0].Interface.Options))
160168
Expect(iface.Type).To(Equal(conf.Uplinks[0].Interface.Type))
161169
Expect(iface.OtherConfig).To(Equal(conf.Uplinks[0].Interface.OtherConfig))
162170
Expect(iface.ExternalIDs).To(Equal(conf.Uplinks[0].Interface.ExternalIDs))
163171
Expect(iface.MTURequest).To(Equal(conf.Uplinks[0].Interface.MTURequest))
172+
internalPort, ok := ports[conf.Name]
173+
Expect(ok).To(BeTrue())
174+
internalIface, ok := interfaces[conf.Name]
175+
Expect(ok).To(BeTrue())
176+
Expect(internalPort.Interfaces).To(ContainElement(internalIface.UUID))
177+
Expect(internalIface.Options).To(BeNil())
178+
Expect(internalIface.Type).To(Equal("internal"))
179+
Expect(internalIface.OtherConfig).To(BeNil())
180+
Expect(internalIface.ExternalIDs).To(BeNil())
164181
}
165182

166183
var _ = Describe("OVS", func() {

0 commit comments

Comments
 (0)