router

package
v0.0.0-...-6b04af2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

README

Router IOModule

This module is a Router that implements a simplified version of routing algorithm, port management and arp responder.

API:

  • AddRoutingTableEntry(network string, netmask string, outputIface string, nexthop string): Adds a routing table entry in the routing table of the router

  • network: network address to reach. (e.g. 10.0.1.0)

  • netmask: network address netmask. (e.g 255.255.255.0)

  • outputIface: output interface (router port).

  • nexthop: represents the next hop (e.g. 130.192.123.123). If 0 the network is locally reachable.

  • AddRoutingTableEntryLocal(network string, netmask string, outputIface string): As previous API, but forces the nexthop parameter to 0 and force the network to be local to a router port.

  • ConfigureInterface(ifaceName string, ip string, netmask string, mac string): Configure the interface Ip and Mac address of the router port. In addition set the correspondent routing table entry to reach the local network attachet to the port.

  • ifaceName: string that identifies the interface name (e.g. if the interface was previously attached to Switch1 use "Switch1")

  • ip: ip address of the interface

  • netmask: netmask address

  • mac: mac address of the port

How to use

Using iovisor-ovn daemon in standalone mode, the user can deploy and configure a single or a chain of IOModules. The entire setup can be deployed starting from a YAML configuration file.

$GOPATH/bin/iovisorovnd -file <configuration.yaml>

Some examples are available in /examples folder:

YAML Configuration Format

The following is an example of the configuration of a router:

[...]
- name: myrouter
  type: router
  config:
    interfaces:
      - name: Switch1
        ip: 10.0.1.254
        netmask: 255.255.255.0
        mac: "7e:ee:c2:01:01:01"

      - name: Switch2
        ip: 10.0.2.254
        netmask: 255.255.255.0
        mac: "7e:ee:c2:02:02:02"

      - name: Nat
        ip: 0.0.0.0
        netmask: 0.0.0.0
        mac: "7e:ee:c2:03:03:03"

    static_routes:
      - network: 130.192.0.0
        netmask: 255.255.0.0
        interface: Switch3
        next_hop: 10.2.2.254

      - network: 10.1.1.0
        netmask: 255.255.255.0
        interface: Switch4
        #If no next_hop set, route of type local

[...]
  • interfaces: defines local interfaces of the router. This primitive set automatically also the routing table entries of type local in order to reach hosts belonging to the defined network.

Limitations

  • The control plane must put ordered entries into the routing table, from longest to shortest prefix.
  • Routing table contains maximum 10 entries.
  • When the router has to forward a packet to an ip address without know the mac address, sent it in broadcast. When someone performs an arp request with that address router arp table is updated and l2 address is successfully completed.

Documentation

Overview

Copyright 2017 Politecnico di Torino

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const CLEANUP_EVERY_N_PACKETS = 5
View Source
const MAX_ENTRY_AGE = 15 * time.Second
View Source
const MAX_QUEUE_LEN = 10
View Source
const SLOWPATH_ARP_LOOKUP_MISS = 2
View Source
const SLOWPATH_ARP_REPLY = 1
View Source
const SLOWPATH_TTL_EXCEEDED = 3

Variables

View Source
var RouterCode = `` /* 10395-byte string literal not displayed */

Functions

This section is empty.

Types

type BufferQueue

type BufferQueue struct {
	// contains filtered or unexported fields
}

type ByMaskLen

type ByMaskLen []RoutingTableEntry

func (ByMaskLen) Len

func (s ByMaskLen) Len() int

func (ByMaskLen) Less

func (s ByMaskLen) Less(i, j int) bool

func (ByMaskLen) Swap

func (s ByMaskLen) Swap(i, j int)

type RouterModule

type RouterModule struct {
	ModuleId     string
	RoutingTable []RoutingTableEntry

	Interfaces   map[string]*RouterModuleInterface
	OutputBuffer map[uint32]*BufferQueue
	PktCounter   int
	// contains filtered or unexported fields
}

func Create

func Create(hc *hover.Client) *RouterModule

func (*RouterModule) AddArpEntry

func (r *RouterModule) AddArpEntry(ip net.IP, mac net.HardwareAddr) (err error)

func (*RouterModule) AddRoutingTableEntry

func (r *RouterModule) AddRoutingTableEntry(network net.IPNet,
	outputIface string, nexthop net.IP) (err error)

Routes in the routing table have to be ordered according to the netmask length. This is because of a limitation in the eBPF datapath (no way to perform LPM there) next hop is a string indicating the ip address of the nexthop, 0.0.0.0 indicates that the network is directly attached to the router.

func (*RouterModule) AddRoutingTableEntryLocal

func (r *RouterModule) AddRoutingTableEntryLocal(network net.IPNet,
	outputIface string) (err error)

A local entry of the routing table indicates that the network interface is directly attached, so there is no need of the next hop address. This function force the routing table entry to be local, pushing 0 as nexthop

func (*RouterModule) AttachExternalInterface

func (r *RouterModule) AttachExternalInterface(ifaceName string) (err error)

func (*RouterModule) AttachToIoModule

func (r *RouterModule) AttachToIoModule(ifaceId int, ifaceName string) (err error)

func (*RouterModule) Configure

func (r *RouterModule) Configure(conf interface{}) (err error)

func (*RouterModule) ConfigureInterface

func (r *RouterModule) ConfigureInterface(ifaceName string, ip net.IP,
	netmask net.IPMask, mac net.HardwareAddr) (err error)

After a interface has been added, it is necessary to configure it before it can be used to route packets TODO I think we have to add next hop parameter here!

func (*RouterModule) Deploy

func (r *RouterModule) Deploy() (err error)

func (*RouterModule) Destroy

func (r *RouterModule) Destroy() (err error)

func (*RouterModule) DetachExternalInterface

func (r *RouterModule) DetachExternalInterface(ifaceName string) (err error)

func (*RouterModule) DetachFromIoModule

func (r *RouterModule) DetachFromIoModule(ifaceName string) (err error)

func (*RouterModule) GetModuleId

func (r *RouterModule) GetModuleId() string

func (*RouterModule) ProcessPacket

func (r *RouterModule) ProcessPacket(p *hover.PacketIn) (err error)

type RouterModuleInterface

type RouterModuleInterface struct {
	IfaceIdRedirectHover int    // Iface id inside hover
	LinkIdHover          string // iomodules Link Id
	IfaceName            string
	IP                   net.IP
	Netmask              net.IPMask
	MAC                  net.HardwareAddr
}

type RoutingTableEntry

type RoutingTableEntry struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL