|
7 | 7 | from core.emane.nodes import EmaneNet
|
8 | 8 | from core.nodes.base import CoreNodeBase
|
9 | 9 | from core.nodes.interface import DEFAULT_MTU, CoreInterface
|
10 |
| -from core.nodes.network import WlanNode |
| 10 | +from core.nodes.network import PtpNet, WlanNode |
| 11 | +from core.nodes.physical import Rj45Node |
11 | 12 |
|
12 | 13 | logger = logging.getLogger(__name__)
|
13 | 14 | GROUP: str = "Quagga"
|
@@ -55,6 +56,20 @@ def get_router_id(node: CoreNodeBase) -> str:
|
55 | 56 | return "0.0.0.0"
|
56 | 57 |
|
57 | 58 |
|
| 59 | +def rj45_check(iface: CoreInterface) -> bool: |
| 60 | + """ |
| 61 | + Helper to detect whether interface is connected an external RJ45 |
| 62 | + link. |
| 63 | + """ |
| 64 | + if iface.net: |
| 65 | + for peer_iface in iface.net.get_ifaces(): |
| 66 | + if peer_iface == iface: |
| 67 | + continue |
| 68 | + if isinstance(peer_iface.node, Rj45Node): |
| 69 | + return True |
| 70 | + return False |
| 71 | + |
| 72 | + |
58 | 73 | class Zebra(ConfigService):
|
59 | 74 | name: str = "zebra"
|
60 | 75 | group: str = GROUP
|
@@ -105,7 +120,13 @@ def data(self) -> Dict[str, Any]:
|
105 | 120 | ip4s.append(str(ip4))
|
106 | 121 | for ip6 in iface.ip6s:
|
107 | 122 | ip6s.append(str(ip6))
|
108 |
| - ifaces.append((iface, ip4s, ip6s, iface.control)) |
| 123 | + configs = [] |
| 124 | + if not iface.control: |
| 125 | + for service in services: |
| 126 | + config = service.quagga_iface_config(iface) |
| 127 | + if config: |
| 128 | + configs.append(config.split("\n")) |
| 129 | + ifaces.append((iface, ip4s, ip6s, configs)) |
109 | 130 |
|
110 | 131 | return dict(
|
111 | 132 | quagga_bin_search=quagga_bin_search,
|
@@ -156,17 +177,32 @@ class Ospfv2(QuaggaService, ConfigService):
|
156 | 177 | ipv4_routing: bool = True
|
157 | 178 |
|
158 | 179 | def quagga_iface_config(self, iface: CoreInterface) -> str:
|
159 |
| - if has_mtu_mismatch(iface): |
160 |
| - return "ip ospf mtu-ignore" |
161 |
| - else: |
162 |
| - return "" |
| 180 | + has_mtu = has_mtu_mismatch(iface) |
| 181 | + has_rj45 = rj45_check(iface) |
| 182 | + is_ptp = isinstance(iface.net, PtpNet) |
| 183 | + data = dict(has_mtu=has_mtu, is_ptp=is_ptp, has_rj45=has_rj45) |
| 184 | + text = """ |
| 185 | + % if has_mtu: |
| 186 | + ip ospf mtu-ignore |
| 187 | + % endif |
| 188 | + % if has_rj45: |
| 189 | + <% return STOP_RENDERING %> |
| 190 | + % endif |
| 191 | + % if is_ptp: |
| 192 | + ip ospf network point-to-point |
| 193 | + % endif |
| 194 | + ip ospf hello-interval 2 |
| 195 | + ip ospf dead-interval 6 |
| 196 | + ip ospf retransmit-interval 5 |
| 197 | + """ |
| 198 | + return self.render_text(text, data) |
163 | 199 |
|
164 | 200 | def quagga_config(self) -> str:
|
165 | 201 | router_id = get_router_id(self.node)
|
166 | 202 | addresses = []
|
167 | 203 | for iface in self.node.get_ifaces(control=False):
|
168 | 204 | for ip4 in iface.ip4s:
|
169 |
| - addresses.append(str(ip4.ip)) |
| 205 | + addresses.append(str(ip4)) |
170 | 206 | data = dict(router_id=router_id, addresses=addresses)
|
171 | 207 | text = """
|
172 | 208 | router ospf
|
|
0 commit comments