Commit 04e946cf authored by Simon Redman's avatar Simon Redman

Add preliminary support for multipath routing

parent e10b11ac
......@@ -22,6 +22,7 @@ import ipaddress
from collections import namedtuple
import json
import logging
import random
import requests
import socket
......@@ -68,7 +69,13 @@ class nlsdnController():
"""
Get the value of the requested attribute of the route
"""
return [attr[1] for attr in route['attrs'] if attr[0] == attr_name].pop()
maybe_value = [attr[1] for attr in route['attrs'] if attr[0] == attr_name]
if len(maybe_value) == 0:
return None
elif len(maybe_value) == 1:
return maybe_value.pop()
else:
raise Exception(f"Too many values found in {route} with attribute name {attr_name}")
def get_routes(self, nlsdn_id: int, filter=None):
"""
......@@ -184,8 +191,13 @@ class nlsdnController():
if route is None:
raise RouteNotFoundError(f"Could not find route for {str(dest_ip)}")
LOG.debug(f"Trying to get output interface for flow matching {nlsdn_match}")
LOG.debug(f"Trying to get output interface for flow matching {nlsdn_match} on dpid {nlsdn_id}")
output_iface = self._get_route_attr(route, "RTA_OIF")
if output_iface is None:
# Multipath routing is more different
multipath = self._get_route_attr(route, "RTA_MULTIPATH")
selected_path = random.choice(multipath)
output_iface = selected_path['oif'] # Wouldn't it be too easy if the format of this OIF were the same as the non-multipath?
match_url = self.NLSDN_TEMPLATE.format(host=management_ip, port=port, endpoint=self.MATCH_ENDPOINT)
action_url = self.NLSDN_TEMPLATE.format(host=management_ip, port=port, endpoint=self.ACTION_ENDPOINT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment