Skip to content

Commit d974ae9

Browse files
committed
Port openshift-sdn-ovs script to go
1 parent 399b442 commit d974ae9

File tree

8 files changed

+157
-244
lines changed

8 files changed

+157
-244
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/${PLATFORM}/sdn-cni-plugin %{buildroot}/opt/cni/bin/openshift-sdn
309306
install -p -m 0755 _output/local/bin/${PLATFORM}/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 & 103 deletions
This file was deleted.

pkg/sdn/plugin/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
253253
// eg, "table=10, priority=100, tun_src=${remote_node_ip}, actions=goto_table:30"
254254
otx.AddFlow("table=10, priority=0, actions=drop")
255255

256-
// Table 20: from OpenShift container; validate IP/MAC, assign tenant-id; filled in by openshift-sdn-ovs
256+
// Table 20: from OpenShift container; validate IP/MAC, assign tenant-id; filled in by setupPodFlows
257257
// eg, "table=20, priority=100, in_port=${ovs_port}, arp, nw_src=${ipaddr}, arp_sha=${macaddr}, actions=load:${tenant_id}->NXM_NX_REG0[], goto_table:30"
258258
// "table=20, priority=100, in_port=${ovs_port}, ip, nw_src=${ipaddr}, actions=load:${tenant_id}->NXM_NX_REG0[], goto_table:30"
259259
// (${tenant_id} is always 0 for single-tenant)
@@ -270,7 +270,7 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
270270
otx.AddFlow("table=30, priority=0, ip, actions=goto_table:100")
271271
otx.AddFlow("table=30, priority=0, arp, actions=drop")
272272

273-
// Table 40: ARP to local container, filled in by openshift-sdn-ovs
273+
// Table 40: ARP to local container, filled in by setupPodFlows
274274
// eg, "table=40, priority=100, arp, nw_dst=${container_ip}, actions=output:${ovs_port}"
275275
otx.AddFlow("table=40, priority=0, actions=drop")
276276

@@ -283,7 +283,7 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
283283
// eg, "table=60, priority=100, reg0=${tenant_id}, ${service_proto}, nw_dst=${service_ip}, tp_dst=${service_port}, actions=load:${tenant_id}->NXM_NX_REG1[], load:2->NXM_NX_REG2[], goto_table:80"
284284
otx.AddFlow("table=60, priority=0, actions=drop")
285285

286-
// Table 70: IP to local container: vnid/port mappings; filled in by openshift-sdn-ovs
286+
// Table 70: IP to local container: vnid/port mappings; filled in by setupPodFlows
287287
// eg, "table=70, priority=100, ip, nw_dst=${ipaddr}, actions=load:${tenant_id}->NXM_NX_REG1[], load:${ovs_port}->NXM_NX_REG2[], goto_table:80"
288288
otx.AddFlow("table=70, priority=0, actions=drop")
289289

pkg/sdn/plugin/node.go

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

236236
log.V(5).Infof("Creating and initializing openshift-sdn pod manager")
237-
node.podManager, err = newPodManager(node.host, node.localSubnetCIDR, node.networkInfo, node.kClient, node.policy, node.mtu)
237+
node.podManager, err = newPodManager(node.host, node.localSubnetCIDR, node.networkInfo, node.kClient, node.policy, node.ovs, node.mtu)
238238
if err != nil {
239239
return err
240240
}

pkg/sdn/plugin/pod.go

Lines changed: 4 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

@@ -35,17 +36,19 @@ type podManager struct {
3536
// Live pod setup/teardown stuff not used in testing code
3637
kClient *kclientset.Clientset
3738
policy osdnPolicy
39+
ovs *ovs.Interface
3840
ipamConfig []byte
3941
mtu uint32
4042
hostportHandler kubehostport.HostportHandler
4143
host knetwork.Host
4244
}
4345

4446
// Creates a new live podManager; used by node code
45-
func newPodManager(host knetwork.Host, localSubnetCIDR string, netInfo *NetworkInfo, kClient *kclientset.Clientset, policy osdnPolicy, mtu uint32) (*podManager, error) {
47+
func newPodManager(host knetwork.Host, localSubnetCIDR string, netInfo *NetworkInfo, kClient *kclientset.Clientset, policy osdnPolicy, ovsif *ovs.Interface, mtu uint32) (*podManager, error) {
4648
pm := newDefaultPodManager(host)
4749
pm.kClient = kClient
4850
pm.policy = policy
51+
pm.ovs = ovsif
4952
pm.mtu = mtu
5053
pm.hostportHandler = kubehostport.NewHostportHandler()
5154
pm.podHandler = pm

0 commit comments

Comments
 (0)