routes_test.go 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
  1. // Copyright 2019 the Kilo authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package mesh
  15. import (
  16. "testing"
  17. "github.com/kylelemons/godebug/pretty"
  18. "github.com/vishvananda/netlink"
  19. "golang.org/x/sys/unix"
  20. "github.com/squat/kilo/pkg/encapsulation"
  21. )
  22. func TestRoutes(t *testing.T) {
  23. nodes, peers, key, port := setup(t)
  24. kiloIface := 0
  25. privIface := 1
  26. tunlIface := 2
  27. mustTopoForGranularityAndHost := func(granularity Granularity, hostname string) *Topology {
  28. return mustTopo(t, nodes, peers, granularity, hostname, port, key, DefaultKiloSubnet, 0)
  29. }
  30. for _, tc := range []struct {
  31. name string
  32. local bool
  33. topology *Topology
  34. strategy encapsulation.Strategy
  35. routes []*netlink.Route
  36. rules []*netlink.Rule
  37. }{
  38. {
  39. name: "logical from a",
  40. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name),
  41. strategy: encapsulation.Never,
  42. routes: []*netlink.Route{
  43. {
  44. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].cidrs[0],
  45. Flags: int(netlink.FLAG_ONLINK),
  46. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  47. LinkIndex: kiloIface,
  48. Protocol: unix.RTPROT_STATIC,
  49. },
  50. {
  51. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  52. Flags: int(netlink.FLAG_ONLINK),
  53. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  54. LinkIndex: kiloIface,
  55. Protocol: unix.RTPROT_STATIC,
  56. },
  57. {
  58. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].cidrs[1],
  59. Flags: int(netlink.FLAG_ONLINK),
  60. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  61. LinkIndex: kiloIface,
  62. Protocol: unix.RTPROT_STATIC,
  63. },
  64. {
  65. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  66. Flags: int(netlink.FLAG_ONLINK),
  67. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  68. LinkIndex: kiloIface,
  69. Protocol: unix.RTPROT_STATIC,
  70. },
  71. {
  72. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[2].cidrs[0],
  73. Flags: int(netlink.FLAG_ONLINK),
  74. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[2].wireGuardIP,
  75. LinkIndex: kiloIface,
  76. Protocol: unix.RTPROT_STATIC,
  77. },
  78. {
  79. Dst: peers["a"].AllowedIPs[0],
  80. LinkIndex: kiloIface,
  81. Protocol: unix.RTPROT_STATIC,
  82. },
  83. {
  84. Dst: peers["a"].AllowedIPs[1],
  85. LinkIndex: kiloIface,
  86. Protocol: unix.RTPROT_STATIC,
  87. },
  88. {
  89. Dst: peers["b"].AllowedIPs[0],
  90. LinkIndex: kiloIface,
  91. Protocol: unix.RTPROT_STATIC,
  92. },
  93. },
  94. },
  95. {
  96. name: "logical from b",
  97. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name),
  98. strategy: encapsulation.Never,
  99. routes: []*netlink.Route{
  100. {
  101. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[0].cidrs[0],
  102. Flags: int(netlink.FLAG_ONLINK),
  103. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  104. LinkIndex: kiloIface,
  105. Protocol: unix.RTPROT_STATIC,
  106. },
  107. {
  108. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  109. Flags: int(netlink.FLAG_ONLINK),
  110. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  111. LinkIndex: kiloIface,
  112. Protocol: unix.RTPROT_STATIC,
  113. },
  114. {
  115. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[2].cidrs[0],
  116. Flags: int(netlink.FLAG_ONLINK),
  117. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[2].wireGuardIP,
  118. LinkIndex: kiloIface,
  119. Protocol: unix.RTPROT_STATIC,
  120. },
  121. {
  122. Dst: peers["a"].AllowedIPs[0],
  123. LinkIndex: kiloIface,
  124. Protocol: unix.RTPROT_STATIC,
  125. },
  126. {
  127. Dst: peers["a"].AllowedIPs[1],
  128. LinkIndex: kiloIface,
  129. Protocol: unix.RTPROT_STATIC,
  130. },
  131. {
  132. Dst: peers["b"].AllowedIPs[0],
  133. LinkIndex: kiloIface,
  134. Protocol: unix.RTPROT_STATIC,
  135. },
  136. },
  137. },
  138. {
  139. name: "logical from c",
  140. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name),
  141. strategy: encapsulation.Never,
  142. routes: []*netlink.Route{
  143. {
  144. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[0].wireGuardIP),
  145. Flags: int(netlink.FLAG_ONLINK),
  146. Gw: nodes["b"].InternalIP.IP,
  147. LinkIndex: privIface,
  148. Protocol: unix.RTPROT_STATIC,
  149. },
  150. {
  151. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[0].cidrs[0],
  152. Flags: int(netlink.FLAG_ONLINK),
  153. Gw: nodes["b"].InternalIP.IP,
  154. LinkIndex: privIface,
  155. Protocol: unix.RTPROT_STATIC,
  156. },
  157. {
  158. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  159. Flags: int(netlink.FLAG_ONLINK),
  160. Gw: nodes["b"].InternalIP.IP,
  161. LinkIndex: privIface,
  162. Protocol: unix.RTPROT_STATIC,
  163. },
  164. {
  165. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[1].wireGuardIP),
  166. Flags: int(netlink.FLAG_ONLINK),
  167. Gw: nodes["b"].InternalIP.IP,
  168. LinkIndex: privIface,
  169. Protocol: unix.RTPROT_STATIC,
  170. },
  171. {
  172. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[2].wireGuardIP),
  173. Flags: int(netlink.FLAG_ONLINK),
  174. Gw: nodes["b"].InternalIP.IP,
  175. LinkIndex: privIface,
  176. Protocol: unix.RTPROT_STATIC,
  177. },
  178. {
  179. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[2].cidrs[0],
  180. Flags: int(netlink.FLAG_ONLINK),
  181. Gw: nodes["b"].InternalIP.IP,
  182. LinkIndex: privIface,
  183. Protocol: unix.RTPROT_STATIC,
  184. },
  185. {
  186. Dst: peers["a"].AllowedIPs[0],
  187. Flags: int(netlink.FLAG_ONLINK),
  188. Gw: nodes["b"].InternalIP.IP,
  189. LinkIndex: privIface,
  190. Protocol: unix.RTPROT_STATIC,
  191. },
  192. {
  193. Dst: peers["a"].AllowedIPs[1],
  194. Flags: int(netlink.FLAG_ONLINK),
  195. Gw: nodes["b"].InternalIP.IP,
  196. LinkIndex: privIface,
  197. Protocol: unix.RTPROT_STATIC,
  198. },
  199. {
  200. Dst: peers["b"].AllowedIPs[0],
  201. Flags: int(netlink.FLAG_ONLINK),
  202. Gw: nodes["b"].InternalIP.IP,
  203. LinkIndex: privIface,
  204. Protocol: unix.RTPROT_STATIC,
  205. },
  206. },
  207. },
  208. {
  209. name: "logical from d",
  210. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name),
  211. strategy: encapsulation.Never,
  212. routes: []*netlink.Route{
  213. {
  214. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[0].cidrs[0],
  215. Flags: int(netlink.FLAG_ONLINK),
  216. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[0].wireGuardIP,
  217. LinkIndex: kiloIface,
  218. Protocol: unix.RTPROT_STATIC,
  219. },
  220. {
  221. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  222. Flags: int(netlink.FLAG_ONLINK),
  223. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[0].wireGuardIP,
  224. LinkIndex: kiloIface,
  225. Protocol: unix.RTPROT_STATIC,
  226. },
  227. {
  228. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[1].cidrs[0],
  229. Flags: int(netlink.FLAG_ONLINK),
  230. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[1].wireGuardIP,
  231. LinkIndex: kiloIface,
  232. Protocol: unix.RTPROT_STATIC,
  233. },
  234. {
  235. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  236. Flags: int(netlink.FLAG_ONLINK),
  237. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[1].wireGuardIP,
  238. LinkIndex: kiloIface,
  239. Protocol: unix.RTPROT_STATIC,
  240. },
  241. {
  242. Dst: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[1].cidrs[1],
  243. Flags: int(netlink.FLAG_ONLINK),
  244. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[1].wireGuardIP,
  245. LinkIndex: kiloIface,
  246. Protocol: unix.RTPROT_STATIC,
  247. },
  248. {
  249. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  250. Flags: int(netlink.FLAG_ONLINK),
  251. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["d"].Name).segments[1].wireGuardIP,
  252. LinkIndex: kiloIface,
  253. Protocol: unix.RTPROT_STATIC,
  254. },
  255. {
  256. Dst: peers["a"].AllowedIPs[0],
  257. LinkIndex: kiloIface,
  258. Protocol: unix.RTPROT_STATIC,
  259. },
  260. {
  261. Dst: peers["a"].AllowedIPs[1],
  262. LinkIndex: kiloIface,
  263. Protocol: unix.RTPROT_STATIC,
  264. },
  265. {
  266. Dst: peers["b"].AllowedIPs[0],
  267. LinkIndex: kiloIface,
  268. Protocol: unix.RTPROT_STATIC,
  269. },
  270. },
  271. },
  272. {
  273. name: "full from a",
  274. topology: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name),
  275. strategy: encapsulation.Never,
  276. routes: []*netlink.Route{
  277. {
  278. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[1].cidrs[0],
  279. Flags: int(netlink.FLAG_ONLINK),
  280. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  281. LinkIndex: kiloIface,
  282. Protocol: unix.RTPROT_STATIC,
  283. },
  284. {
  285. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  286. Flags: int(netlink.FLAG_ONLINK),
  287. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  288. LinkIndex: kiloIface,
  289. Protocol: unix.RTPROT_STATIC,
  290. },
  291. {
  292. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[2].cidrs[0],
  293. Flags: int(netlink.FLAG_ONLINK),
  294. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[2].wireGuardIP,
  295. LinkIndex: kiloIface,
  296. Protocol: unix.RTPROT_STATIC,
  297. },
  298. {
  299. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  300. Flags: int(netlink.FLAG_ONLINK),
  301. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[2].wireGuardIP,
  302. LinkIndex: kiloIface,
  303. Protocol: unix.RTPROT_STATIC,
  304. },
  305. {
  306. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[3].cidrs[0],
  307. Flags: int(netlink.FLAG_ONLINK),
  308. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[3].wireGuardIP,
  309. LinkIndex: kiloIface,
  310. Protocol: unix.RTPROT_STATIC,
  311. },
  312. {
  313. Dst: peers["a"].AllowedIPs[0],
  314. LinkIndex: kiloIface,
  315. Protocol: unix.RTPROT_STATIC,
  316. },
  317. {
  318. Dst: peers["a"].AllowedIPs[1],
  319. LinkIndex: kiloIface,
  320. Protocol: unix.RTPROT_STATIC,
  321. },
  322. {
  323. Dst: peers["b"].AllowedIPs[0],
  324. LinkIndex: kiloIface,
  325. Protocol: unix.RTPROT_STATIC,
  326. },
  327. },
  328. },
  329. {
  330. name: "full from b",
  331. topology: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name),
  332. strategy: encapsulation.Never,
  333. routes: []*netlink.Route{
  334. {
  335. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[0].cidrs[0],
  336. Flags: int(netlink.FLAG_ONLINK),
  337. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  338. LinkIndex: kiloIface,
  339. Protocol: unix.RTPROT_STATIC,
  340. },
  341. {
  342. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  343. Flags: int(netlink.FLAG_ONLINK),
  344. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  345. LinkIndex: kiloIface,
  346. Protocol: unix.RTPROT_STATIC,
  347. },
  348. {
  349. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[2].cidrs[0],
  350. Flags: int(netlink.FLAG_ONLINK),
  351. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[2].wireGuardIP,
  352. LinkIndex: kiloIface,
  353. Protocol: unix.RTPROT_STATIC,
  354. },
  355. {
  356. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  357. Flags: int(netlink.FLAG_ONLINK),
  358. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[2].wireGuardIP,
  359. LinkIndex: kiloIface,
  360. Protocol: unix.RTPROT_STATIC,
  361. },
  362. {
  363. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[3].cidrs[0],
  364. Flags: int(netlink.FLAG_ONLINK),
  365. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[3].wireGuardIP,
  366. LinkIndex: kiloIface,
  367. Protocol: unix.RTPROT_STATIC,
  368. },
  369. {
  370. Dst: peers["a"].AllowedIPs[0],
  371. LinkIndex: kiloIface,
  372. Protocol: unix.RTPROT_STATIC,
  373. },
  374. {
  375. Dst: peers["a"].AllowedIPs[1],
  376. LinkIndex: kiloIface,
  377. Protocol: unix.RTPROT_STATIC,
  378. },
  379. {
  380. Dst: peers["b"].AllowedIPs[0],
  381. LinkIndex: kiloIface,
  382. Protocol: unix.RTPROT_STATIC,
  383. },
  384. },
  385. },
  386. {
  387. name: "full from c",
  388. topology: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name),
  389. strategy: encapsulation.Never,
  390. routes: []*netlink.Route{
  391. {
  392. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[0].cidrs[0],
  393. Flags: int(netlink.FLAG_ONLINK),
  394. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[0].wireGuardIP,
  395. LinkIndex: kiloIface,
  396. Protocol: unix.RTPROT_STATIC,
  397. },
  398. {
  399. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  400. Flags: int(netlink.FLAG_ONLINK),
  401. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[0].wireGuardIP,
  402. LinkIndex: kiloIface,
  403. Protocol: unix.RTPROT_STATIC,
  404. },
  405. {
  406. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[1].cidrs[0],
  407. Flags: int(netlink.FLAG_ONLINK),
  408. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[1].wireGuardIP,
  409. LinkIndex: kiloIface,
  410. Protocol: unix.RTPROT_STATIC,
  411. },
  412. {
  413. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  414. Flags: int(netlink.FLAG_ONLINK),
  415. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[1].wireGuardIP,
  416. LinkIndex: kiloIface,
  417. Protocol: unix.RTPROT_STATIC,
  418. },
  419. {
  420. Dst: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[3].cidrs[0],
  421. Flags: int(netlink.FLAG_ONLINK),
  422. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[3].wireGuardIP,
  423. LinkIndex: kiloIface,
  424. Protocol: unix.RTPROT_STATIC,
  425. },
  426. {
  427. Dst: peers["a"].AllowedIPs[0],
  428. LinkIndex: kiloIface,
  429. Protocol: unix.RTPROT_STATIC,
  430. },
  431. {
  432. Dst: peers["a"].AllowedIPs[1],
  433. LinkIndex: kiloIface,
  434. Protocol: unix.RTPROT_STATIC,
  435. },
  436. {
  437. Dst: peers["b"].AllowedIPs[0],
  438. LinkIndex: kiloIface,
  439. Protocol: unix.RTPROT_STATIC,
  440. },
  441. },
  442. },
  443. {
  444. name: "logical from a local",
  445. local: true,
  446. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name),
  447. strategy: encapsulation.Never,
  448. routes: []*netlink.Route{
  449. {
  450. Dst: nodes["b"].Subnet,
  451. Flags: int(netlink.FLAG_ONLINK),
  452. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  453. LinkIndex: kiloIface,
  454. Protocol: unix.RTPROT_STATIC,
  455. },
  456. {
  457. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  458. Flags: int(netlink.FLAG_ONLINK),
  459. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  460. LinkIndex: kiloIface,
  461. Protocol: unix.RTPROT_STATIC,
  462. },
  463. {
  464. Dst: nodes["c"].Subnet,
  465. Flags: int(netlink.FLAG_ONLINK),
  466. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  467. LinkIndex: kiloIface,
  468. Protocol: unix.RTPROT_STATIC,
  469. },
  470. {
  471. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  472. Flags: int(netlink.FLAG_ONLINK),
  473. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  474. LinkIndex: kiloIface,
  475. Protocol: unix.RTPROT_STATIC,
  476. },
  477. {
  478. Dst: nodes["d"].Subnet,
  479. Flags: int(netlink.FLAG_ONLINK),
  480. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[2].wireGuardIP,
  481. LinkIndex: kiloIface,
  482. Protocol: unix.RTPROT_STATIC,
  483. },
  484. {
  485. Dst: peers["a"].AllowedIPs[0],
  486. LinkIndex: kiloIface,
  487. Protocol: unix.RTPROT_STATIC,
  488. },
  489. {
  490. Dst: peers["a"].AllowedIPs[1],
  491. LinkIndex: kiloIface,
  492. Protocol: unix.RTPROT_STATIC,
  493. },
  494. {
  495. Dst: peers["b"].AllowedIPs[0],
  496. LinkIndex: kiloIface,
  497. Protocol: unix.RTPROT_STATIC,
  498. },
  499. },
  500. },
  501. {
  502. name: "logical from a local always",
  503. local: true,
  504. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name),
  505. strategy: encapsulation.Always,
  506. routes: []*netlink.Route{
  507. {
  508. Dst: nodes["b"].Subnet,
  509. Flags: int(netlink.FLAG_ONLINK),
  510. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  511. LinkIndex: kiloIface,
  512. Protocol: unix.RTPROT_STATIC,
  513. },
  514. {
  515. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  516. Flags: int(netlink.FLAG_ONLINK),
  517. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  518. LinkIndex: kiloIface,
  519. Protocol: unix.RTPROT_STATIC,
  520. },
  521. {
  522. Dst: nodes["c"].Subnet,
  523. Flags: int(netlink.FLAG_ONLINK),
  524. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  525. LinkIndex: kiloIface,
  526. Protocol: unix.RTPROT_STATIC,
  527. },
  528. {
  529. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  530. Flags: int(netlink.FLAG_ONLINK),
  531. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  532. LinkIndex: kiloIface,
  533. Protocol: unix.RTPROT_STATIC,
  534. },
  535. {
  536. Dst: nodes["d"].Subnet,
  537. Flags: int(netlink.FLAG_ONLINK),
  538. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["a"].Name).segments[2].wireGuardIP,
  539. LinkIndex: kiloIface,
  540. Protocol: unix.RTPROT_STATIC,
  541. },
  542. {
  543. Dst: peers["a"].AllowedIPs[0],
  544. LinkIndex: kiloIface,
  545. Protocol: unix.RTPROT_STATIC,
  546. },
  547. {
  548. Dst: peers["a"].AllowedIPs[1],
  549. LinkIndex: kiloIface,
  550. Protocol: unix.RTPROT_STATIC,
  551. },
  552. {
  553. Dst: peers["b"].AllowedIPs[0],
  554. LinkIndex: kiloIface,
  555. Protocol: unix.RTPROT_STATIC,
  556. },
  557. },
  558. },
  559. {
  560. name: "logical from b local",
  561. local: true,
  562. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name),
  563. strategy: encapsulation.Never,
  564. routes: []*netlink.Route{
  565. {
  566. Dst: nodes["a"].Subnet,
  567. Flags: int(netlink.FLAG_ONLINK),
  568. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  569. LinkIndex: kiloIface,
  570. Protocol: unix.RTPROT_STATIC,
  571. },
  572. {
  573. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  574. Flags: int(netlink.FLAG_ONLINK),
  575. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  576. LinkIndex: kiloIface,
  577. Protocol: unix.RTPROT_STATIC,
  578. },
  579. {
  580. Dst: nodes["c"].Subnet,
  581. Flags: int(netlink.FLAG_ONLINK),
  582. Gw: nodes["c"].InternalIP.IP,
  583. LinkIndex: privIface,
  584. Protocol: unix.RTPROT_STATIC,
  585. },
  586. {
  587. Dst: nodes["d"].Subnet,
  588. Flags: int(netlink.FLAG_ONLINK),
  589. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[2].wireGuardIP,
  590. LinkIndex: kiloIface,
  591. Protocol: unix.RTPROT_STATIC,
  592. },
  593. {
  594. Dst: peers["a"].AllowedIPs[0],
  595. LinkIndex: kiloIface,
  596. Protocol: unix.RTPROT_STATIC,
  597. },
  598. {
  599. Dst: peers["a"].AllowedIPs[1],
  600. LinkIndex: kiloIface,
  601. Protocol: unix.RTPROT_STATIC,
  602. },
  603. {
  604. Dst: peers["b"].AllowedIPs[0],
  605. LinkIndex: kiloIface,
  606. Protocol: unix.RTPROT_STATIC,
  607. },
  608. },
  609. },
  610. {
  611. name: "logical from b local always",
  612. local: true,
  613. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name),
  614. strategy: encapsulation.Always,
  615. routes: []*netlink.Route{
  616. {
  617. Dst: nodes["a"].Subnet,
  618. Flags: int(netlink.FLAG_ONLINK),
  619. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  620. LinkIndex: kiloIface,
  621. Protocol: unix.RTPROT_STATIC,
  622. },
  623. {
  624. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  625. Flags: int(netlink.FLAG_ONLINK),
  626. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  627. LinkIndex: kiloIface,
  628. Protocol: unix.RTPROT_STATIC,
  629. },
  630. {
  631. Dst: nodes["c"].Subnet,
  632. Flags: int(netlink.FLAG_ONLINK),
  633. Gw: nodes["c"].InternalIP.IP,
  634. LinkIndex: tunlIface,
  635. Protocol: unix.RTPROT_STATIC,
  636. },
  637. {
  638. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  639. Flags: int(netlink.FLAG_ONLINK),
  640. Gw: nodes["c"].InternalIP.IP,
  641. LinkIndex: tunlIface,
  642. Protocol: unix.RTPROT_STATIC,
  643. Table: kiloTableIndex,
  644. },
  645. {
  646. Dst: nodes["d"].Subnet,
  647. Flags: int(netlink.FLAG_ONLINK),
  648. Gw: mustTopoForGranularityAndHost(LogicalGranularity, nodes["b"].Name).segments[2].wireGuardIP,
  649. LinkIndex: kiloIface,
  650. Protocol: unix.RTPROT_STATIC,
  651. },
  652. {
  653. Dst: peers["a"].AllowedIPs[0],
  654. LinkIndex: kiloIface,
  655. Protocol: unix.RTPROT_STATIC,
  656. },
  657. {
  658. Dst: peers["a"].AllowedIPs[1],
  659. LinkIndex: kiloIface,
  660. Protocol: unix.RTPROT_STATIC,
  661. },
  662. {
  663. Dst: peers["b"].AllowedIPs[0],
  664. LinkIndex: kiloIface,
  665. Protocol: unix.RTPROT_STATIC,
  666. },
  667. },
  668. rules: []*netlink.Rule{
  669. defaultRule(&netlink.Rule{
  670. Src: nodes["b"].Subnet,
  671. Dst: nodes["c"].InternalIP,
  672. Table: kiloTableIndex,
  673. }),
  674. defaultRule(&netlink.Rule{
  675. Dst: nodes["c"].InternalIP,
  676. IifName: DefaultKiloInterface,
  677. Table: kiloTableIndex,
  678. }),
  679. },
  680. },
  681. {
  682. name: "logical from c local",
  683. local: true,
  684. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name),
  685. strategy: encapsulation.Never,
  686. routes: []*netlink.Route{
  687. {
  688. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[0].wireGuardIP),
  689. Flags: int(netlink.FLAG_ONLINK),
  690. Gw: nodes["b"].InternalIP.IP,
  691. LinkIndex: privIface,
  692. Protocol: unix.RTPROT_STATIC,
  693. },
  694. {
  695. Dst: nodes["a"].Subnet,
  696. Flags: int(netlink.FLAG_ONLINK),
  697. Gw: nodes["b"].InternalIP.IP,
  698. LinkIndex: privIface,
  699. Protocol: unix.RTPROT_STATIC,
  700. },
  701. {
  702. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  703. Flags: int(netlink.FLAG_ONLINK),
  704. Gw: nodes["b"].InternalIP.IP,
  705. LinkIndex: privIface,
  706. Protocol: unix.RTPROT_STATIC,
  707. },
  708. {
  709. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[1].wireGuardIP),
  710. Flags: int(netlink.FLAG_ONLINK),
  711. Gw: nodes["b"].InternalIP.IP,
  712. LinkIndex: privIface,
  713. Protocol: unix.RTPROT_STATIC,
  714. },
  715. {
  716. Dst: nodes["b"].Subnet,
  717. Flags: int(netlink.FLAG_ONLINK),
  718. Gw: nodes["b"].InternalIP.IP,
  719. LinkIndex: privIface,
  720. Protocol: unix.RTPROT_STATIC,
  721. },
  722. {
  723. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[2].wireGuardIP),
  724. Flags: int(netlink.FLAG_ONLINK),
  725. Gw: nodes["b"].InternalIP.IP,
  726. LinkIndex: privIface,
  727. Protocol: unix.RTPROT_STATIC,
  728. },
  729. {
  730. Dst: nodes["d"].Subnet,
  731. Flags: int(netlink.FLAG_ONLINK),
  732. Gw: nodes["b"].InternalIP.IP,
  733. LinkIndex: privIface,
  734. Protocol: unix.RTPROT_STATIC,
  735. },
  736. {
  737. Dst: peers["a"].AllowedIPs[0],
  738. Flags: int(netlink.FLAG_ONLINK),
  739. Gw: nodes["b"].InternalIP.IP,
  740. LinkIndex: privIface,
  741. Protocol: unix.RTPROT_STATIC,
  742. },
  743. {
  744. Dst: peers["a"].AllowedIPs[1],
  745. Flags: int(netlink.FLAG_ONLINK),
  746. Gw: nodes["b"].InternalIP.IP,
  747. LinkIndex: privIface,
  748. Protocol: unix.RTPROT_STATIC,
  749. },
  750. {
  751. Dst: peers["b"].AllowedIPs[0],
  752. Flags: int(netlink.FLAG_ONLINK),
  753. Gw: nodes["b"].InternalIP.IP,
  754. LinkIndex: privIface,
  755. Protocol: unix.RTPROT_STATIC,
  756. },
  757. },
  758. },
  759. {
  760. name: "logical from c local always",
  761. local: true,
  762. topology: mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name),
  763. strategy: encapsulation.Always,
  764. routes: []*netlink.Route{
  765. {
  766. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[0].wireGuardIP),
  767. Flags: int(netlink.FLAG_ONLINK),
  768. Gw: nodes["b"].InternalIP.IP,
  769. LinkIndex: tunlIface,
  770. Protocol: unix.RTPROT_STATIC,
  771. },
  772. {
  773. Dst: nodes["a"].Subnet,
  774. Flags: int(netlink.FLAG_ONLINK),
  775. Gw: nodes["b"].InternalIP.IP,
  776. LinkIndex: tunlIface,
  777. Protocol: unix.RTPROT_STATIC,
  778. },
  779. {
  780. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  781. Flags: int(netlink.FLAG_ONLINK),
  782. Gw: nodes["b"].InternalIP.IP,
  783. LinkIndex: tunlIface,
  784. Protocol: unix.RTPROT_STATIC,
  785. },
  786. {
  787. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[1].wireGuardIP),
  788. Flags: int(netlink.FLAG_ONLINK),
  789. Gw: nodes["b"].InternalIP.IP,
  790. LinkIndex: tunlIface,
  791. Protocol: unix.RTPROT_STATIC,
  792. },
  793. {
  794. Dst: nodes["b"].Subnet,
  795. Flags: int(netlink.FLAG_ONLINK),
  796. Gw: nodes["b"].InternalIP.IP,
  797. LinkIndex: tunlIface,
  798. Protocol: unix.RTPROT_STATIC,
  799. },
  800. {
  801. Dst: nodes["b"].InternalIP,
  802. Flags: int(netlink.FLAG_ONLINK),
  803. Gw: nodes["b"].InternalIP.IP,
  804. LinkIndex: tunlIface,
  805. Protocol: unix.RTPROT_STATIC,
  806. Table: kiloTableIndex,
  807. },
  808. {
  809. Dst: oneAddressCIDR(mustTopoForGranularityAndHost(LogicalGranularity, nodes["c"].Name).segments[2].wireGuardIP),
  810. Flags: int(netlink.FLAG_ONLINK),
  811. Gw: nodes["b"].InternalIP.IP,
  812. LinkIndex: tunlIface,
  813. Protocol: unix.RTPROT_STATIC,
  814. },
  815. {
  816. Dst: nodes["d"].Subnet,
  817. Flags: int(netlink.FLAG_ONLINK),
  818. Gw: nodes["b"].InternalIP.IP,
  819. LinkIndex: tunlIface,
  820. Protocol: unix.RTPROT_STATIC,
  821. },
  822. {
  823. Dst: peers["a"].AllowedIPs[0],
  824. Flags: int(netlink.FLAG_ONLINK),
  825. Gw: nodes["b"].InternalIP.IP,
  826. LinkIndex: tunlIface,
  827. Protocol: unix.RTPROT_STATIC,
  828. },
  829. {
  830. Dst: peers["a"].AllowedIPs[1],
  831. Flags: int(netlink.FLAG_ONLINK),
  832. Gw: nodes["b"].InternalIP.IP,
  833. LinkIndex: tunlIface,
  834. Protocol: unix.RTPROT_STATIC,
  835. },
  836. {
  837. Dst: peers["b"].AllowedIPs[0],
  838. Flags: int(netlink.FLAG_ONLINK),
  839. Gw: nodes["b"].InternalIP.IP,
  840. LinkIndex: tunlIface,
  841. Protocol: unix.RTPROT_STATIC,
  842. },
  843. },
  844. rules: []*netlink.Rule{
  845. defaultRule(&netlink.Rule{
  846. Src: nodes["c"].Subnet,
  847. Dst: nodes["b"].InternalIP,
  848. Table: kiloTableIndex,
  849. }),
  850. },
  851. },
  852. {
  853. name: "full from a local",
  854. local: true,
  855. topology: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name),
  856. strategy: encapsulation.Never,
  857. routes: []*netlink.Route{
  858. {
  859. Dst: nodes["b"].Subnet,
  860. Flags: int(netlink.FLAG_ONLINK),
  861. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  862. LinkIndex: kiloIface,
  863. Protocol: unix.RTPROT_STATIC,
  864. },
  865. {
  866. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  867. Flags: int(netlink.FLAG_ONLINK),
  868. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[1].wireGuardIP,
  869. LinkIndex: kiloIface,
  870. Protocol: unix.RTPROT_STATIC,
  871. },
  872. {
  873. Dst: nodes["c"].Subnet,
  874. Flags: int(netlink.FLAG_ONLINK),
  875. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[2].wireGuardIP,
  876. LinkIndex: kiloIface,
  877. Protocol: unix.RTPROT_STATIC,
  878. },
  879. {
  880. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  881. Flags: int(netlink.FLAG_ONLINK),
  882. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[2].wireGuardIP,
  883. LinkIndex: kiloIface,
  884. Protocol: unix.RTPROT_STATIC,
  885. },
  886. {
  887. Dst: nodes["d"].Subnet,
  888. Flags: int(netlink.FLAG_ONLINK),
  889. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["a"].Name).segments[3].wireGuardIP,
  890. LinkIndex: kiloIface,
  891. Protocol: unix.RTPROT_STATIC,
  892. },
  893. {
  894. Dst: peers["a"].AllowedIPs[0],
  895. LinkIndex: kiloIface,
  896. Protocol: unix.RTPROT_STATIC,
  897. },
  898. {
  899. Dst: peers["a"].AllowedIPs[1],
  900. LinkIndex: kiloIface,
  901. Protocol: unix.RTPROT_STATIC,
  902. },
  903. {
  904. Dst: peers["b"].AllowedIPs[0],
  905. LinkIndex: kiloIface,
  906. Protocol: unix.RTPROT_STATIC,
  907. },
  908. },
  909. },
  910. {
  911. name: "full from b local",
  912. local: true,
  913. topology: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name),
  914. strategy: encapsulation.Never,
  915. routes: []*netlink.Route{
  916. {
  917. Dst: nodes["a"].Subnet,
  918. Flags: int(netlink.FLAG_ONLINK),
  919. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  920. LinkIndex: kiloIface,
  921. Protocol: unix.RTPROT_STATIC,
  922. },
  923. {
  924. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  925. Flags: int(netlink.FLAG_ONLINK),
  926. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[0].wireGuardIP,
  927. LinkIndex: kiloIface,
  928. Protocol: unix.RTPROT_STATIC,
  929. },
  930. {
  931. Dst: nodes["c"].Subnet,
  932. Flags: int(netlink.FLAG_ONLINK),
  933. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[2].wireGuardIP,
  934. LinkIndex: kiloIface,
  935. Protocol: unix.RTPROT_STATIC,
  936. },
  937. {
  938. Dst: oneAddressCIDR(nodes["c"].InternalIP.IP),
  939. Flags: int(netlink.FLAG_ONLINK),
  940. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[2].wireGuardIP,
  941. LinkIndex: kiloIface,
  942. Protocol: unix.RTPROT_STATIC,
  943. },
  944. {
  945. Dst: nodes["d"].Subnet,
  946. Flags: int(netlink.FLAG_ONLINK),
  947. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["b"].Name).segments[3].wireGuardIP,
  948. LinkIndex: kiloIface,
  949. Protocol: unix.RTPROT_STATIC,
  950. },
  951. {
  952. Dst: peers["a"].AllowedIPs[0],
  953. LinkIndex: kiloIface,
  954. Protocol: unix.RTPROT_STATIC,
  955. },
  956. {
  957. Dst: peers["a"].AllowedIPs[1],
  958. LinkIndex: kiloIface,
  959. Protocol: unix.RTPROT_STATIC,
  960. },
  961. {
  962. Dst: peers["b"].AllowedIPs[0],
  963. LinkIndex: kiloIface,
  964. Protocol: unix.RTPROT_STATIC,
  965. },
  966. },
  967. },
  968. {
  969. name: "full from c local",
  970. local: true,
  971. topology: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name),
  972. strategy: encapsulation.Never,
  973. routes: []*netlink.Route{
  974. {
  975. Dst: nodes["a"].Subnet,
  976. Flags: int(netlink.FLAG_ONLINK),
  977. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[0].wireGuardIP,
  978. LinkIndex: kiloIface,
  979. Protocol: unix.RTPROT_STATIC,
  980. },
  981. {
  982. Dst: oneAddressCIDR(nodes["a"].InternalIP.IP),
  983. Flags: int(netlink.FLAG_ONLINK),
  984. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[0].wireGuardIP,
  985. LinkIndex: kiloIface,
  986. Protocol: unix.RTPROT_STATIC,
  987. },
  988. {
  989. Dst: nodes["b"].Subnet,
  990. Flags: int(netlink.FLAG_ONLINK),
  991. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[1].wireGuardIP,
  992. LinkIndex: kiloIface,
  993. Protocol: unix.RTPROT_STATIC,
  994. },
  995. {
  996. Dst: oneAddressCIDR(nodes["b"].InternalIP.IP),
  997. Flags: int(netlink.FLAG_ONLINK),
  998. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[1].wireGuardIP,
  999. LinkIndex: kiloIface,
  1000. Protocol: unix.RTPROT_STATIC,
  1001. },
  1002. {
  1003. Dst: nodes["d"].Subnet,
  1004. Flags: int(netlink.FLAG_ONLINK),
  1005. Gw: mustTopoForGranularityAndHost(FullGranularity, nodes["c"].Name).segments[3].wireGuardIP,
  1006. LinkIndex: kiloIface,
  1007. Protocol: unix.RTPROT_STATIC,
  1008. },
  1009. {
  1010. Dst: peers["a"].AllowedIPs[0],
  1011. LinkIndex: kiloIface,
  1012. Protocol: unix.RTPROT_STATIC,
  1013. },
  1014. {
  1015. Dst: peers["a"].AllowedIPs[1],
  1016. LinkIndex: kiloIface,
  1017. Protocol: unix.RTPROT_STATIC,
  1018. },
  1019. {
  1020. Dst: peers["b"].AllowedIPs[0],
  1021. LinkIndex: kiloIface,
  1022. Protocol: unix.RTPROT_STATIC,
  1023. },
  1024. },
  1025. },
  1026. } {
  1027. routes, rules := tc.topology.Routes(DefaultKiloInterface, kiloIface, privIface, tunlIface, tc.local, encapsulation.NewIPIP(tc.strategy))
  1028. if diff := pretty.Compare(routes, tc.routes); diff != "" {
  1029. t.Errorf("test case %q: got diff: %v", tc.name, diff)
  1030. }
  1031. if diff := pretty.Compare(rules, tc.rules); diff != "" {
  1032. t.Errorf("test case %q: got diff: %v", tc.name, diff)
  1033. }
  1034. }
  1035. }