Skip to content

Commit 1ac54b6

Browse files
committed
Port openshift-sdn-ovs script to go
1 parent 183f105 commit 1ac54b6

File tree

8 files changed

+170
-250
lines changed

8 files changed

+170
-250
lines changed

contrib/node/install-sdn.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ os::provision::install-sdn() {
1414
mkdir -p -m u+rwx,g+rwx,o+rx "${target_confdir}"
1515
mkdir -p -m u+rwx,g+rwx,o+rx "${target_cnidir}"
1616

17-
local osdn_plugin_path="${deployed_root}/pkg/sdn/plugin"
18-
install -m u+rwx,g+rwx,o+rx "${osdn_plugin_path}/bin/openshift-sdn-ovs" "${target_bindir}"
19-
install -m u+rw,g+rw,o+r "${osdn_plugin_path}/sdn-cni-plugin/80-openshift-sdn.conf" "${target_confdir}"
17+
install -m u+rw,g+rw,o+r "${deployed_root}/pkg/sdn/plugin/sdn-cni-plugin/80-openshift-sdn.conf" "${target_confdir}"
2018

2119
install -m u+rwx,g+rwx,o+rx "${binaries_path}/sdn-cni-plugin" "${target_cnidir}/openshift-sdn"
2220
install -m u+rwx,g+rwx,o+rx "${binaries_path}/host-local" "${target_cnidir}"

hack/dind-cluster.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ function copy-runtime() {
203203
cp "$(os::util::find::built_binary host-local)" "${target}"
204204
cp "$(os::util::find::built_binary loopback)" "${target}"
205205
cp "$(os::util::find::built_binary sdn-cni-plugin)" "${target}/openshift-sdn"
206-
local osdn_plugin_path="${origin_root}/pkg/sdn/plugin"
207-
cp "${osdn_plugin_path}/bin/openshift-sdn-ovs" "${target}"
208-
cp "${osdn_plugin_path}/sdn-cni-plugin/80-openshift-sdn.conf" "${target}"
206+
cp "${origin_root}/pkg/sdn/plugin/sdn-cni-plugin/80-openshift-sdn.conf" "${target}"
209207
}
210208

211209
function wait-for-cluster() {

origin.spec

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ install -d -m 0755 %{buildroot}%{_sysconfdir}/cni/net.d
301301
pushd pkg/sdn/plugin/sdn-cni-plugin
302302
install -p -m 0644 80-openshift-sdn.conf %{buildroot}%{_sysconfdir}/cni/net.d
303303
popd
304-
pushd pkg/sdn/plugin/bin
305-
install -p -m 0755 openshift-sdn-ovs %{buildroot}%{_bindir}/openshift-sdn-ovs
306-
popd
307304
install -d -m 0755 %{buildroot}/opt/cni/bin
308305
install -p -m 0755 _output/local/bin/linux/amd64/sdn-cni-plugin %{buildroot}/opt/cni/bin/openshift-sdn
309306
install -p -m 0755 _output/local/bin/linux/amd64/host-local %{buildroot}/opt/cni/bin
@@ -474,7 +471,6 @@ fi
474471
%dir %{_unitdir}/%{name}-node.service.d/
475472
%dir %{_sysconfdir}/cni/net.d
476473
%dir /opt/cni/bin
477-
%{_bindir}/openshift-sdn-ovs
478474
%{_unitdir}/%{name}-node.service.d/openshift-sdn-ovs.conf
479475
%{_sysconfdir}/cni/net.d/80-openshift-sdn.conf
480476
/opt/cni/bin/*

pkg/sdn/plugin/bin/openshift-sdn-ovs

Lines changed: 0 additions & 108 deletions
This file was deleted.

pkg/sdn/plugin/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
248248
// eg, "table=1, priority=100, tun_src=${remote_node_ip}, actions=goto_table:5"
249249
otx.AddFlow("table=1, priority=0, actions=drop")
250250

251-
// Table 2: from OpenShift container; validate IP/MAC, assign tenant-id; filled in by openshift-sdn-ovs
251+
// Table 2: from OpenShift container; validate IP/MAC, assign tenant-id; filled in by setupPodFlows()
252252
// eg, "table=2, priority=100, in_port=${ovs_port}, arp, nw_src=${ipaddr}, arp_sha=${macaddr}, actions=load:${tenant_id}->NXM_NX_REG0[], goto_table:5"
253253
// "table=2, priority=100, in_port=${ovs_port}, ip, nw_src=${ipaddr}, actions=load:${tenant_id}->NXM_NX_REG0[], goto_table:3"
254254
// (${tenant_id} is always 0 for single-tenant)
@@ -273,11 +273,11 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
273273
otx.AddFlow("table=5, priority=0, ip, actions=goto_table:9")
274274
otx.AddFlow("table=5, priority=0, arp, actions=drop")
275275

276-
// Table 6: ARP to container, filled in by openshift-sdn-ovs
276+
// Table 6: ARP to container, filled in by setupPodFlows()
277277
// eg, "table=6, priority=100, arp, nw_dst=${container_ip}, actions=output:${ovs_port}"
278278
otx.AddFlow("table=6, priority=0, actions=drop")
279279

280-
// Table 7: IP to container; filled in by openshift-sdn-ovs
280+
// Table 7: IP to container; filled in by setupPodFlows()
281281
// eg, "table=7, priority=100, reg0=0, ip, nw_dst=${ipaddr}, actions=output:${ovs_port}"
282282
// eg, "table=7, priority=100, reg0=${tenant_id}, ip, nw_dst=${ipaddr}, actions=output:${ovs_port}"
283283
otx.AddFlow("table=7, priority=0, actions=drop")

pkg/sdn/plugin/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (node *OsdnNode) Start() error {
217217
})
218218

219219
log.V(5).Infof("Creating and initializing openshift-sdn pod manager")
220-
node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.mtu)
220+
node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.ovs, node.mtu)
221221
if err != nil {
222222
return err
223223
}

pkg/sdn/plugin/pod.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
99
"github.com/openshift/origin/pkg/util/netutils"
10+
"github.com/openshift/origin/pkg/util/ovs"
1011

1112
"github.com/golang/glog"
1213

@@ -36,18 +37,20 @@ type podManager struct {
3637
multitenant bool
3738
kClient *kclientset.Clientset
3839
vnids *nodeVNIDMap
40+
ovs *ovs.Interface
3941
ipamConfig []byte
4042
mtu uint32
4143
hostportHandler kubehostport.HostportHandler
4244
host knetwork.Host
4345
}
4446

4547
// Creates a new live podManager; used by node code
46-
func newPodManager(host knetwork.Host, multitenant bool, localSubnetCIDR string, netInfo *NetworkInfo, kClient *kclientset.Clientset, vnids *nodeVNIDMap, mtu uint32) (*podManager, error) {
48+
func newPodManager(host knetwork.Host, multitenant bool, localSubnetCIDR string, netInfo *NetworkInfo, kClient *kclientset.Clientset, vnids *nodeVNIDMap, ovsif *ovs.Interface, mtu uint32) (*podManager, error) {
4749
pm := newDefaultPodManager(host)
4850
pm.multitenant = multitenant
4951
pm.kClient = kClient
5052
pm.vnids = vnids
53+
pm.ovs = ovsif
5154
pm.mtu = mtu
5255
pm.hostportHandler = kubehostport.NewHostportHandler()
5356
pm.podHandler = pm
@@ -140,6 +143,15 @@ func (m *podManager) getRunningPods() []*kubehostport.RunningPod {
140143
return pods
141144
}
142145

146+
// Get the VNID of a namespace
147+
func (m *podManager) getVNID(namespace string) (uint32, error) {
148+
if m.multitenant {
149+
return m.vnids.GetVNID(namespace)
150+
} else {
151+
return 0, nil
152+
}
153+
}
154+
143155
// Add a request to the podManager CNI request queue
144156
func (m *podManager) addRequest(request *cniserver.PodRequest) {
145157
m.requests <- request

0 commit comments

Comments
 (0)