Skip to content

Commit

Permalink
Port openshift-sdn-ovs script to go
Browse files Browse the repository at this point in the history
  • Loading branch information
danwinship committed Dec 7, 2016
1 parent 183f105 commit 1ac54b6
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 250 deletions.
4 changes: 1 addition & 3 deletions contrib/node/install-sdn.sh
Expand Up @@ -14,9 +14,7 @@ os::provision::install-sdn() {
mkdir -p -m u+rwx,g+rwx,o+rx "${target_confdir}"
mkdir -p -m u+rwx,g+rwx,o+rx "${target_cnidir}"

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

install -m u+rwx,g+rwx,o+rx "${binaries_path}/sdn-cni-plugin" "${target_cnidir}/openshift-sdn"
install -m u+rwx,g+rwx,o+rx "${binaries_path}/host-local" "${target_cnidir}"
Expand Down
4 changes: 1 addition & 3 deletions hack/dind-cluster.sh
Expand Up @@ -203,9 +203,7 @@ function copy-runtime() {
cp "$(os::util::find::built_binary host-local)" "${target}"
cp "$(os::util::find::built_binary loopback)" "${target}"
cp "$(os::util::find::built_binary sdn-cni-plugin)" "${target}/openshift-sdn"
local osdn_plugin_path="${origin_root}/pkg/sdn/plugin"
cp "${osdn_plugin_path}/bin/openshift-sdn-ovs" "${target}"
cp "${osdn_plugin_path}/sdn-cni-plugin/80-openshift-sdn.conf" "${target}"
cp "${origin_root}/pkg/sdn/plugin/sdn-cni-plugin/80-openshift-sdn.conf" "${target}"
}

function wait-for-cluster() {
Expand Down
4 changes: 0 additions & 4 deletions origin.spec
Expand Up @@ -301,9 +301,6 @@ install -d -m 0755 %{buildroot}%{_sysconfdir}/cni/net.d
pushd pkg/sdn/plugin/sdn-cni-plugin
install -p -m 0644 80-openshift-sdn.conf %{buildroot}%{_sysconfdir}/cni/net.d
popd
pushd pkg/sdn/plugin/bin
install -p -m 0755 openshift-sdn-ovs %{buildroot}%{_bindir}/openshift-sdn-ovs
popd
install -d -m 0755 %{buildroot}/opt/cni/bin
install -p -m 0755 _output/local/bin/linux/amd64/sdn-cni-plugin %{buildroot}/opt/cni/bin/openshift-sdn
install -p -m 0755 _output/local/bin/linux/amd64/host-local %{buildroot}/opt/cni/bin
Expand Down Expand Up @@ -474,7 +471,6 @@ fi
%dir %{_unitdir}/%{name}-node.service.d/
%dir %{_sysconfdir}/cni/net.d
%dir /opt/cni/bin
%{_bindir}/openshift-sdn-ovs
%{_unitdir}/%{name}-node.service.d/openshift-sdn-ovs.conf
%{_sysconfdir}/cni/net.d/80-openshift-sdn.conf
/opt/cni/bin/*
Expand Down
108 changes: 0 additions & 108 deletions pkg/sdn/plugin/bin/openshift-sdn-ovs

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/sdn/plugin/controller.go
Expand Up @@ -248,7 +248,7 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
// eg, "table=1, priority=100, tun_src=${remote_node_ip}, actions=goto_table:5"
otx.AddFlow("table=1, priority=0, actions=drop")

// Table 2: from OpenShift container; validate IP/MAC, assign tenant-id; filled in by openshift-sdn-ovs
// Table 2: from OpenShift container; validate IP/MAC, assign tenant-id; filled in by setupPodFlows()
// 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"
// "table=2, priority=100, in_port=${ovs_port}, ip, nw_src=${ipaddr}, actions=load:${tenant_id}->NXM_NX_REG0[], goto_table:3"
// (${tenant_id} is always 0 for single-tenant)
Expand All @@ -273,11 +273,11 @@ func (plugin *OsdnNode) SetupSDN() (bool, error) {
otx.AddFlow("table=5, priority=0, ip, actions=goto_table:9")
otx.AddFlow("table=5, priority=0, arp, actions=drop")

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

// Table 7: IP to container; filled in by openshift-sdn-ovs
// Table 7: IP to container; filled in by setupPodFlows()
// eg, "table=7, priority=100, reg0=0, ip, nw_dst=${ipaddr}, actions=output:${ovs_port}"
// eg, "table=7, priority=100, reg0=${tenant_id}, ip, nw_dst=${ipaddr}, actions=output:${ovs_port}"
otx.AddFlow("table=7, priority=0, actions=drop")
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdn/plugin/node.go
Expand Up @@ -217,7 +217,7 @@ func (node *OsdnNode) Start() error {
})

log.V(5).Infof("Creating and initializing openshift-sdn pod manager")
node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.mtu)
node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.ovs, node.mtu)
if err != nil {
return err
}
Expand Down
14 changes: 13 additions & 1 deletion pkg/sdn/plugin/pod.go
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/openshift/origin/pkg/sdn/plugin/cniserver"
"github.com/openshift/origin/pkg/util/netutils"
"github.com/openshift/origin/pkg/util/ovs"

"github.com/golang/glog"

Expand Down Expand Up @@ -36,18 +37,20 @@ type podManager struct {
multitenant bool
kClient *kclientset.Clientset
vnids *nodeVNIDMap
ovs *ovs.Interface
ipamConfig []byte
mtu uint32
hostportHandler kubehostport.HostportHandler
host knetwork.Host
}

// Creates a new live podManager; used by node code
func newPodManager(host knetwork.Host, multitenant bool, localSubnetCIDR string, netInfo *NetworkInfo, kClient *kclientset.Clientset, vnids *nodeVNIDMap, mtu uint32) (*podManager, error) {
func newPodManager(host knetwork.Host, multitenant bool, localSubnetCIDR string, netInfo *NetworkInfo, kClient *kclientset.Clientset, vnids *nodeVNIDMap, ovsif *ovs.Interface, mtu uint32) (*podManager, error) {
pm := newDefaultPodManager(host)
pm.multitenant = multitenant
pm.kClient = kClient
pm.vnids = vnids
pm.ovs = ovsif
pm.mtu = mtu
pm.hostportHandler = kubehostport.NewHostportHandler()
pm.podHandler = pm
Expand Down Expand Up @@ -140,6 +143,15 @@ func (m *podManager) getRunningPods() []*kubehostport.RunningPod {
return pods
}

// Get the VNID of a namespace
func (m *podManager) getVNID(namespace string) (uint32, error) {
if m.multitenant {
return m.vnids.GetVNID(namespace)
} else {
return 0, nil
}
}

// Add a request to the podManager CNI request queue
func (m *podManager) addRequest(request *cniserver.PodRequest) {
m.requests <- request
Expand Down

0 comments on commit 1ac54b6

Please sign in to comment.