| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "network-generator.h" |
| 4 |
#include "tests.h" |
| 5 |
|
| 6 |
static void test_network_one(const char *ifname, const char *key, const char *value, const char *expected) { |
| 7 |
_cleanup_(context_clear) Context context = {}; |
| 8 |
_cleanup_free_ char *output = NULL; |
| 9 |
Network *network; |
| 10 |
|
| 11 |
log_debug("/* %s(%s=%s) */", __func__, key, value); |
| 12 |
|
| 13 |
ASSERT_OK(parse_cmdline_item(key, value, &context)); |
| 14 |
ASSERT_NOT_NULL((network = network_get(&context, ifname))); |
| 15 |
ASSERT_OK(network_format(network, &output)); |
| 16 |
ASSERT_STREQ(output, expected); |
| 17 |
} |
| 18 |
|
| 19 |
static void test_network_two(const char *ifname, |
| 20 |
const char *key1, const char *value1, |
| 21 |
const char *key2, const char *value2, |
| 22 |
const char *expected) { |
| 23 |
_cleanup_(context_clear) Context context = {}; |
| 24 |
_cleanup_free_ char *output = NULL; |
| 25 |
Network *network; |
| 26 |
|
| 27 |
log_debug("/* %s(%s=%s, %s=%s) */", __func__, key1, value1, key2, value2); |
| 28 |
|
| 29 |
ASSERT_OK(parse_cmdline_item(key1, value1, &context)); |
| 30 |
ASSERT_OK(parse_cmdline_item(key2, value2, &context)); |
| 31 |
context_finalize_bootif(&context); |
| 32 |
ASSERT_OK(context_merge_networks(&context)); |
| 33 |
ASSERT_NOT_NULL((network = network_get(&context, ifname))); |
| 34 |
ASSERT_OK(network_format(network, &output)); |
| 35 |
ASSERT_STREQ(output, expected); |
| 36 |
} |
| 37 |
|
| 38 |
static void test_network_three(const char *ifname, |
| 39 |
const char *key1, const char *value1, |
| 40 |
const char *key2, const char *value2, |
| 41 |
const char *key3, const char *value3, |
| 42 |
const char *expected) { |
| 43 |
_cleanup_(context_clear) Context context = {}; |
| 44 |
_cleanup_free_ char *output = NULL; |
| 45 |
Network *network; |
| 46 |
|
| 47 |
log_debug("/* %s(%s=%s, %s=%s, %s=%s) */", __func__, key1, value1, key2, value2, key3, value3); |
| 48 |
|
| 49 |
ASSERT_OK(parse_cmdline_item(key1, value1, &context)); |
| 50 |
ASSERT_OK(parse_cmdline_item(key2, value2, &context)); |
| 51 |
ASSERT_OK(parse_cmdline_item(key3, value3, &context)); |
| 52 |
context_finalize_bootif(&context); |
| 53 |
ASSERT_OK(context_merge_networks(&context)); |
| 54 |
|
| 55 |
network = network_get(&context, ifname); |
| 56 |
if (expected) { |
| 57 |
ASSERT_NOT_NULL(network); |
| 58 |
ASSERT_OK(network_format(network, &output)); |
| 59 |
ASSERT_STREQ(output, expected); |
| 60 |
} else |
| 61 |
ASSERT_NULL(network); |
| 62 |
} |
| 63 |
|
| 64 |
static void test_netdev_one(const char *ifname, const char *key, const char *value, const char *expected) { |
| 65 |
_cleanup_(context_clear) Context context = {}; |
| 66 |
_cleanup_free_ char *output = NULL; |
| 67 |
NetDev *netdev; |
| 68 |
|
| 69 |
log_debug("/* %s(%s=%s) */", __func__, key, value); |
| 70 |
|
| 71 |
ASSERT_OK(parse_cmdline_item(key, value, &context)); |
| 72 |
ASSERT_NOT_NULL((netdev = netdev_get(&context, ifname))); |
| 73 |
ASSERT_OK(netdev_format(netdev, &output)); |
| 74 |
ASSERT_STREQ(output, expected); |
| 75 |
} |
| 76 |
|
| 77 |
static void test_link_one(const char *filename, const char *key, const char *value, const char *expected) { |
| 78 |
_cleanup_(context_clear) Context context = {}; |
| 79 |
_cleanup_free_ char *output = NULL; |
| 80 |
Link *link; |
| 81 |
|
| 82 |
log_debug("/* %s(%s=%s) */", __func__, key, value); |
| 83 |
|
| 84 |
ASSERT_OK(parse_cmdline_item(key, value, &context)); |
| 85 |
ASSERT_NOT_NULL((link = link_get(&context, filename))); |
| 86 |
ASSERT_OK(link_format(link, &output)); |
| 87 |
ASSERT_STREQ(output, expected); |
| 88 |
} |
| 89 |
|
| 90 |
int main(int argc, char *argv[]) { |
| 91 |
test_setup_logging(LOG_DEBUG); |
| 92 |
|
| 93 |
test_network_one("", "ip", "dhcp6", |
| 94 |
"[Match]\n" |
| 95 |
"Kind=!*\n" |
| 96 |
"Type=!loopback\n" |
| 97 |
"\n[Link]\n" |
| 98 |
"\n[Network]\n" |
| 99 |
"DHCP=ipv6\n" |
| 100 |
"\n[DHCP]\n" |
| 101 |
); |
| 102 |
|
| 103 |
test_network_one("eth0", "ip", "eth0:dhcp", |
| 104 |
"[Match]\n" |
| 105 |
"Name=eth0\n" |
| 106 |
"\n[Link]\n" |
| 107 |
"\n[Network]\n" |
| 108 |
"DHCP=ipv4\n" |
| 109 |
"\n[DHCP]\n" |
| 110 |
); |
| 111 |
|
| 112 |
test_network_one("eth0", "ip", "eth0:dhcp:1530", |
| 113 |
"[Match]\n" |
| 114 |
"Name=eth0\n" |
| 115 |
"\n[Link]\n" |
| 116 |
"MTUBytes=1530\n" |
| 117 |
"\n[Network]\n" |
| 118 |
"DHCP=ipv4\n" |
| 119 |
"\n[DHCP]\n" |
| 120 |
); |
| 121 |
|
| 122 |
test_network_one("eth0", "ip", "eth0:dhcp:1530:00:11:22:33:44:55", |
| 123 |
"[Match]\n" |
| 124 |
"Name=eth0\n" |
| 125 |
"\n[Link]\n" |
| 126 |
"MACAddress=00:11:22:33:44:55\n" |
| 127 |
"MTUBytes=1530\n" |
| 128 |
"\n[Network]\n" |
| 129 |
"DHCP=ipv4\n" |
| 130 |
"\n[DHCP]\n" |
| 131 |
); |
| 132 |
|
| 133 |
test_network_one("eth0", "ip", "10.99.37.44::10.99.10.1:255.255.0.0::eth0:off", |
| 134 |
"[Match]\n" |
| 135 |
"Name=eth0\n" |
| 136 |
"\n[Link]\n" |
| 137 |
"\n[Network]\n" |
| 138 |
"DHCP=no\n" |
| 139 |
"LinkLocalAddressing=no\n" |
| 140 |
"IPv6AcceptRA=no\n" |
| 141 |
"\n[DHCP]\n" |
| 142 |
"\n[Address]\n" |
| 143 |
"Address=10.99.37.44/16\n" |
| 144 |
"\n[Route]\n" |
| 145 |
"Gateway=10.99.10.1\n" |
| 146 |
); |
| 147 |
|
| 148 |
test_network_one("eth0", "ip", "192.168.0.10::192.168.0.1:255.255.255.0:hogehoge:eth0:on", |
| 149 |
"[Match]\n" |
| 150 |
"Name=eth0\n" |
| 151 |
"\n[Link]\n" |
| 152 |
"\n[Network]\n" |
| 153 |
"DHCP=yes\n" |
| 154 |
"\n[DHCP]\n" |
| 155 |
"Hostname=hogehoge\n" |
| 156 |
"\n[Address]\n" |
| 157 |
"Address=192.168.0.10/24\n" |
| 158 |
"\n[Route]\n" |
| 159 |
"Gateway=192.168.0.1\n" |
| 160 |
); |
| 161 |
|
| 162 |
test_network_one("eth0", "ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on", |
| 163 |
"[Match]\n" |
| 164 |
"Name=eth0\n" |
| 165 |
"\n[Link]\n" |
| 166 |
"\n[Network]\n" |
| 167 |
"DHCP=yes\n" |
| 168 |
"\n[DHCP]\n" |
| 169 |
"Hostname=hogehoge\n" |
| 170 |
"\n[Address]\n" |
| 171 |
"Address=192.168.0.10/24\n" |
| 172 |
"Peer=192.168.0.2\n" |
| 173 |
"\n[Route]\n" |
| 174 |
"Gateway=192.168.0.1\n" |
| 175 |
); |
| 176 |
|
| 177 |
test_network_one("eth0", "ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:1530", |
| 178 |
"[Match]\n" |
| 179 |
"Name=eth0\n" |
| 180 |
"\n[Link]\n" |
| 181 |
"MTUBytes=1530\n" |
| 182 |
"\n[Network]\n" |
| 183 |
"DHCP=yes\n" |
| 184 |
"\n[DHCP]\n" |
| 185 |
"Hostname=hogehoge\n" |
| 186 |
"\n[Address]\n" |
| 187 |
"Address=192.168.0.10/24\n" |
| 188 |
"Peer=192.168.0.2\n" |
| 189 |
"\n[Route]\n" |
| 190 |
"Gateway=192.168.0.1\n" |
| 191 |
); |
| 192 |
|
| 193 |
test_network_one("eth0", "ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:1530:00:11:22:33:44:55", |
| 194 |
"[Match]\n" |
| 195 |
"Name=eth0\n" |
| 196 |
"\n[Link]\n" |
| 197 |
"MACAddress=00:11:22:33:44:55\n" |
| 198 |
"MTUBytes=1530\n" |
| 199 |
"\n[Network]\n" |
| 200 |
"DHCP=yes\n" |
| 201 |
"\n[DHCP]\n" |
| 202 |
"Hostname=hogehoge\n" |
| 203 |
"\n[Address]\n" |
| 204 |
"Address=192.168.0.10/24\n" |
| 205 |
"Peer=192.168.0.2\n" |
| 206 |
"\n[Route]\n" |
| 207 |
"Gateway=192.168.0.1\n" |
| 208 |
); |
| 209 |
|
| 210 |
test_network_one("eth0", "ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:10.10.10.10", |
| 211 |
"[Match]\n" |
| 212 |
"Name=eth0\n" |
| 213 |
"\n[Link]\n" |
| 214 |
"\n[Network]\n" |
| 215 |
"DHCP=yes\n" |
| 216 |
"DNS=10.10.10.10\n" |
| 217 |
"\n[DHCP]\n" |
| 218 |
"Hostname=hogehoge\n" |
| 219 |
"\n[Address]\n" |
| 220 |
"Address=192.168.0.10/24\n" |
| 221 |
"Peer=192.168.0.2\n" |
| 222 |
"\n[Route]\n" |
| 223 |
"Gateway=192.168.0.1\n" |
| 224 |
); |
| 225 |
|
| 226 |
test_network_one("eth0", "ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:10.10.10.10:10.10.10.11", |
| 227 |
"[Match]\n" |
| 228 |
"Name=eth0\n" |
| 229 |
"\n[Link]\n" |
| 230 |
"\n[Network]\n" |
| 231 |
"DHCP=yes\n" |
| 232 |
"DNS=10.10.10.10\n" |
| 233 |
"DNS=10.10.10.11\n" |
| 234 |
"\n[DHCP]\n" |
| 235 |
"Hostname=hogehoge\n" |
| 236 |
"\n[Address]\n" |
| 237 |
"Address=192.168.0.10/24\n" |
| 238 |
"Peer=192.168.0.2\n" |
| 239 |
"\n[Route]\n" |
| 240 |
"Gateway=192.168.0.1\n" |
| 241 |
); |
| 242 |
|
| 243 |
test_network_one("eth0", "ip", "192.168.0.10::192.168.0.1:255.255.255.0::eth0:on:10.10.10.10:10.10.10.11:10.10.10.161", |
| 244 |
"[Match]\n" |
| 245 |
"Name=eth0\n" |
| 246 |
"\n[Link]\n" |
| 247 |
"\n[Network]\n" |
| 248 |
"DHCP=yes\n" |
| 249 |
"DNS=10.10.10.10\n" |
| 250 |
"DNS=10.10.10.11\n" |
| 251 |
"NTP=10.10.10.161\n" |
| 252 |
"\n[DHCP]\n" |
| 253 |
"\n[Address]\n" |
| 254 |
"Address=192.168.0.10/24\n" |
| 255 |
"\n[Route]\n" |
| 256 |
"Gateway=192.168.0.1\n" |
| 257 |
); |
| 258 |
|
| 259 |
test_network_one("eth0", "ip", "192.168.0.10::192.168.0.1:255.255.255.0::eth0:on:10.10.10.10::10.10.10.161", |
| 260 |
"[Match]\n" |
| 261 |
"Name=eth0\n" |
| 262 |
"\n[Link]\n" |
| 263 |
"\n[Network]\n" |
| 264 |
"DHCP=yes\n" |
| 265 |
"DNS=10.10.10.10\n" |
| 266 |
"NTP=10.10.10.161\n" |
| 267 |
"\n[DHCP]\n" |
| 268 |
"\n[Address]\n" |
| 269 |
"Address=192.168.0.10/24\n" |
| 270 |
"\n[Route]\n" |
| 271 |
"Gateway=192.168.0.1\n" |
| 272 |
); |
| 273 |
|
| 274 |
test_network_one("eth0", "ip", "192.168.0.10::192.168.0.1:255.255.255.0::eth0:on:::10.10.10.161", |
| 275 |
"[Match]\n" |
| 276 |
"Name=eth0\n" |
| 277 |
"\n[Link]\n" |
| 278 |
"\n[Network]\n" |
| 279 |
"DHCP=yes\n" |
| 280 |
"NTP=10.10.10.161\n" |
| 281 |
"\n[DHCP]\n" |
| 282 |
"\n[Address]\n" |
| 283 |
"Address=192.168.0.10/24\n" |
| 284 |
"\n[Route]\n" |
| 285 |
"Gateway=192.168.0.1\n" |
| 286 |
); |
| 287 |
|
| 288 |
test_network_one("eth0", "ip", "[2001:1234:56:8f63::10]::[2001:1234:56:8f63::1]:64:hogehoge:eth0:on", |
| 289 |
"[Match]\n" |
| 290 |
"Name=eth0\n" |
| 291 |
"\n[Link]\n" |
| 292 |
"\n[Network]\n" |
| 293 |
"DHCP=yes\n" |
| 294 |
"\n[DHCP]\n" |
| 295 |
"Hostname=hogehoge\n" |
| 296 |
"\n[Address]\n" |
| 297 |
"Address=2001:1234:56:8f63::10/64\n" |
| 298 |
"\n[Route]\n" |
| 299 |
"Gateway=2001:1234:56:8f63::1\n" |
| 300 |
); |
| 301 |
|
| 302 |
test_network_one("eth0", "ip", "[2001:1234:56:8f63::10]:[2001:1234:56:8f63::2]:[2001:1234:56:8f63::1]:64:hogehoge:eth0:on", |
| 303 |
"[Match]\n" |
| 304 |
"Name=eth0\n" |
| 305 |
"\n[Link]\n" |
| 306 |
"\n[Network]\n" |
| 307 |
"DHCP=yes\n" |
| 308 |
"\n[DHCP]\n" |
| 309 |
"Hostname=hogehoge\n" |
| 310 |
"\n[Address]\n" |
| 311 |
"Address=2001:1234:56:8f63::10/64\n" |
| 312 |
"Peer=2001:1234:56:8f63::2\n" |
| 313 |
"\n[Route]\n" |
| 314 |
"Gateway=2001:1234:56:8f63::1\n" |
| 315 |
); |
| 316 |
|
| 317 |
test_network_one("", "rd.route", "10.1.2.3/16:10.0.2.3", |
| 318 |
"[Match]\n" |
| 319 |
"Kind=!*\n" |
| 320 |
"Type=!loopback\n" |
| 321 |
"\n[Link]\n" |
| 322 |
"\n[Network]\n" |
| 323 |
"\n[DHCP]\n" |
| 324 |
"\n[Route]\n" |
| 325 |
"Destination=10.1.2.3/16\n" |
| 326 |
"Gateway=10.0.2.3\n" |
| 327 |
); |
| 328 |
|
| 329 |
test_network_one("eth0", "rd.route", "10.1.2.3/16:10.0.2.3:eth0", |
| 330 |
"[Match]\n" |
| 331 |
"Name=eth0\n" |
| 332 |
"\n[Link]\n" |
| 333 |
"\n[Network]\n" |
| 334 |
"\n[DHCP]\n" |
| 335 |
"\n[Route]\n" |
| 336 |
"Destination=10.1.2.3/16\n" |
| 337 |
"Gateway=10.0.2.3\n" |
| 338 |
); |
| 339 |
|
| 340 |
test_network_one("", "nameserver", "10.1.2.3", |
| 341 |
"[Match]\n" |
| 342 |
"Kind=!*\n" |
| 343 |
"Type=!loopback\n" |
| 344 |
"\n[Link]\n" |
| 345 |
"\n[Network]\n" |
| 346 |
"DNS=10.1.2.3\n" |
| 347 |
"\n[DHCP]\n" |
| 348 |
); |
| 349 |
|
| 350 |
test_network_one("", "rd.peerdns", "0", |
| 351 |
"[Match]\n" |
| 352 |
"Kind=!*\n" |
| 353 |
"Type=!loopback\n" |
| 354 |
"\n[Link]\n" |
| 355 |
"\n[Network]\n" |
| 356 |
"\n[DHCP]\n" |
| 357 |
"UseDNS=no\n" |
| 358 |
); |
| 359 |
|
| 360 |
test_network_one("", "rd.peerdns", "1", |
| 361 |
"[Match]\n" |
| 362 |
"Kind=!*\n" |
| 363 |
"Type=!loopback\n" |
| 364 |
"\n[Link]\n" |
| 365 |
"\n[Network]\n" |
| 366 |
"\n[DHCP]\n" |
| 367 |
"UseDNS=yes\n" |
| 368 |
); |
| 369 |
|
| 370 |
test_network_two("eth0", "vlan", "vlan99:eth0", "vlan", "vlan98:eth0", |
| 371 |
"[Match]\n" |
| 372 |
"Name=eth0\n" |
| 373 |
"\n[Link]\n" |
| 374 |
"\n[Network]\n" |
| 375 |
"VLAN=vlan99\n" |
| 376 |
"VLAN=vlan98\n" |
| 377 |
"\n[DHCP]\n" |
| 378 |
); |
| 379 |
|
| 380 |
test_network_one("eth0", "bridge", "bridge99:eth0,eth1", |
| 381 |
"[Match]\n" |
| 382 |
"Name=eth0\n" |
| 383 |
"\n[Link]\n" |
| 384 |
"\n[Network]\n" |
| 385 |
"Bridge=bridge99\n" |
| 386 |
"\n[DHCP]\n" |
| 387 |
); |
| 388 |
|
| 389 |
test_network_one("eth1", "bridge", "bridge99:eth0,eth1", |
| 390 |
"[Match]\n" |
| 391 |
"Name=eth1\n" |
| 392 |
"\n[Link]\n" |
| 393 |
"\n[Network]\n" |
| 394 |
"Bridge=bridge99\n" |
| 395 |
"\n[DHCP]\n" |
| 396 |
); |
| 397 |
|
| 398 |
test_network_one("eth0", "bond", "bond99:eth0,eth1", |
| 399 |
"[Match]\n" |
| 400 |
"Name=eth0\n" |
| 401 |
"\n[Link]\n" |
| 402 |
"\n[Network]\n" |
| 403 |
"Bond=bond99\n" |
| 404 |
"\n[DHCP]\n" |
| 405 |
); |
| 406 |
|
| 407 |
test_network_one("eth1", "bond", "bond99:eth0,eth1::1530", |
| 408 |
"[Match]\n" |
| 409 |
"Name=eth1\n" |
| 410 |
"\n[Link]\n" |
| 411 |
"\n[Network]\n" |
| 412 |
"Bond=bond99\n" |
| 413 |
"\n[DHCP]\n" |
| 414 |
); |
| 415 |
|
| 416 |
test_netdev_one("bridge99", "bridge", "bridge99:", |
| 417 |
"[NetDev]\n" |
| 418 |
"Kind=bridge\n" |
| 419 |
"Name=bridge99\n" |
| 420 |
); |
| 421 |
|
| 422 |
test_netdev_one("bridge99", "bridge", "bridge99:,,,", |
| 423 |
"[NetDev]\n" |
| 424 |
"Kind=bridge\n" |
| 425 |
"Name=bridge99\n" |
| 426 |
); |
| 427 |
|
| 428 |
test_netdev_one("bond99", "bond", "bond99:", |
| 429 |
"[NetDev]\n" |
| 430 |
"Kind=bond\n" |
| 431 |
"Name=bond99\n" |
| 432 |
); |
| 433 |
|
| 434 |
test_netdev_one("bond99", "bond", "bond99::hogehoge:1530", |
| 435 |
"[NetDev]\n" |
| 436 |
"Kind=bond\n" |
| 437 |
"Name=bond99\n" |
| 438 |
"MTUBytes=1530\n" |
| 439 |
); |
| 440 |
|
| 441 |
test_netdev_one("bond99", "bond", "bond99:eth0,eth1::1530", |
| 442 |
"[NetDev]\n" |
| 443 |
"Kind=bond\n" |
| 444 |
"Name=bond99\n" |
| 445 |
"MTUBytes=1530\n" |
| 446 |
); |
| 447 |
|
| 448 |
test_netdev_one("vlan123", "vlan", "vlan123:eth0", |
| 449 |
"[NetDev]\n" |
| 450 |
"Kind=vlan\n" |
| 451 |
"Name=vlan123\n" |
| 452 |
"\n[VLAN]\n" |
| 453 |
"Id=123\n" |
| 454 |
); |
| 455 |
|
| 456 |
test_netdev_one("vlan0013", "vlan", "vlan0013:eth0", |
| 457 |
"[NetDev]\n" |
| 458 |
"Kind=vlan\n" |
| 459 |
"Name=vlan0013\n" |
| 460 |
"\n[VLAN]\n" |
| 461 |
"Id=11\n" /* 0013 (octal) -> 11 */ |
| 462 |
); |
| 463 |
|
| 464 |
test_netdev_one("eth0.123", "vlan", "eth0.123:eth0", |
| 465 |
"[NetDev]\n" |
| 466 |
"Kind=vlan\n" |
| 467 |
"Name=eth0.123\n" |
| 468 |
"\n[VLAN]\n" |
| 469 |
"Id=123\n" |
| 470 |
); |
| 471 |
|
| 472 |
test_netdev_one("eth0.0013", "vlan", "eth0.0013:eth0", |
| 473 |
"[NetDev]\n" |
| 474 |
"Kind=vlan\n" |
| 475 |
"Name=eth0.0013\n" |
| 476 |
"\n[VLAN]\n" |
| 477 |
"Id=11\n" /* 0013 (octal) -> 11 */ |
| 478 |
); |
| 479 |
|
| 480 |
test_link_one("hogehoge", "ifname", "hogehoge:00:11:22:33:44:55", |
| 481 |
"[Match]\n" |
| 482 |
"MACAddress=00:11:22:33:44:55\n" |
| 483 |
"\n[Link]\n" |
| 484 |
"Name=hogehoge\n" |
| 485 |
); |
| 486 |
|
| 487 |
test_link_one("001122334455", "net.ifname-policy", "keep,kernel,database,onboard,slot,path,mac,00:11:22:33:44:55", |
| 488 |
"[Match]\n" |
| 489 |
"MACAddress=00:11:22:33:44:55\n" |
| 490 |
"\n[Link]\n" |
| 491 |
"NamePolicy=keep kernel database onboard slot path mac\n" |
| 492 |
"AlternativeNamesPolicy=database onboard slot path mac\n" |
| 493 |
); |
| 494 |
|
| 495 |
test_link_one("default", "net.ifname-policy", "keep,kernel,database,onboard,slot,path,mac", |
| 496 |
"[Match]\n" |
| 497 |
"OriginalName=*\n" |
| 498 |
"\n[Link]\n" |
| 499 |
"NamePolicy=keep kernel database onboard slot path mac\n" |
| 500 |
"AlternativeNamesPolicy=database onboard slot path mac\n" |
| 501 |
); |
| 502 |
|
| 503 |
test_network_two("eth0", |
| 504 |
"ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:10.10.10.10:10.10.10.11", |
| 505 |
"rd.route", "10.1.2.3/16:10.0.2.3", |
| 506 |
"[Match]\n" |
| 507 |
"Name=eth0\n" |
| 508 |
"\n[Link]\n" |
| 509 |
"\n[Network]\n" |
| 510 |
"DHCP=yes\n" |
| 511 |
"DNS=10.10.10.10\n" |
| 512 |
"DNS=10.10.10.11\n" |
| 513 |
"\n[DHCP]\n" |
| 514 |
"Hostname=hogehoge\n" |
| 515 |
"\n[Address]\n" |
| 516 |
"Address=192.168.0.10/24\n" |
| 517 |
"Peer=192.168.0.2\n" |
| 518 |
"\n[Route]\n" |
| 519 |
"Destination=10.1.2.3/16\n" |
| 520 |
"Gateway=10.0.2.3\n" |
| 521 |
"\n[Route]\n" |
| 522 |
"Gateway=192.168.0.1\n" |
| 523 |
); |
| 524 |
|
| 525 |
test_network_two("eth0", |
| 526 |
"ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on", |
| 527 |
"nameserver", "10.1.2.3", |
| 528 |
"[Match]\n" |
| 529 |
"Name=eth0\n" |
| 530 |
"\n[Link]\n" |
| 531 |
"\n[Network]\n" |
| 532 |
"DHCP=yes\n" |
| 533 |
"DNS=10.1.2.3\n" |
| 534 |
"\n[DHCP]\n" |
| 535 |
"Hostname=hogehoge\n" |
| 536 |
"\n[Address]\n" |
| 537 |
"Address=192.168.0.10/24\n" |
| 538 |
"Peer=192.168.0.2\n" |
| 539 |
"\n[Route]\n" |
| 540 |
"Gateway=192.168.0.1\n" |
| 541 |
); |
| 542 |
|
| 543 |
test_network_two("eth0", |
| 544 |
"ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:10.10.10.10:10.10.10.11", |
| 545 |
"nameserver", "10.1.2.3", |
| 546 |
"[Match]\n" |
| 547 |
"Name=eth0\n" |
| 548 |
"\n[Link]\n" |
| 549 |
"\n[Network]\n" |
| 550 |
"DHCP=yes\n" |
| 551 |
"DNS=10.10.10.10\n" |
| 552 |
"DNS=10.10.10.11\n" |
| 553 |
"DNS=10.1.2.3\n" |
| 554 |
"\n[DHCP]\n" |
| 555 |
"Hostname=hogehoge\n" |
| 556 |
"\n[Address]\n" |
| 557 |
"Address=192.168.0.10/24\n" |
| 558 |
"Peer=192.168.0.2\n" |
| 559 |
"\n[Route]\n" |
| 560 |
"Gateway=192.168.0.1\n" |
| 561 |
); |
| 562 |
|
| 563 |
test_network_two("eth0", |
| 564 |
"ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:10.10.10.10:10.10.10.11", |
| 565 |
"rd.peerdns", "1", |
| 566 |
"[Match]\n" |
| 567 |
"Name=eth0\n" |
| 568 |
"\n[Link]\n" |
| 569 |
"\n[Network]\n" |
| 570 |
"DHCP=yes\n" |
| 571 |
"DNS=10.10.10.10\n" |
| 572 |
"DNS=10.10.10.11\n" |
| 573 |
"\n[DHCP]\n" |
| 574 |
"Hostname=hogehoge\n" |
| 575 |
"UseDNS=yes\n" |
| 576 |
"\n[Address]\n" |
| 577 |
"Address=192.168.0.10/24\n" |
| 578 |
"Peer=192.168.0.2\n" |
| 579 |
"\n[Route]\n" |
| 580 |
"Gateway=192.168.0.1\n" |
| 581 |
); |
| 582 |
|
| 583 |
test_network_two("eth0", |
| 584 |
"ip", "192.168.0.10:192.168.0.2:192.168.0.1:255.255.255.0:hogehoge:eth0:on:10.10.10.10:10.10.10.11", |
| 585 |
"bridge", "bridge99:eth0,eth1", |
| 586 |
"[Match]\n" |
| 587 |
"Name=eth0\n" |
| 588 |
"\n[Link]\n" |
| 589 |
"\n[Network]\n" |
| 590 |
"DHCP=yes\n" |
| 591 |
"DNS=10.10.10.10\n" |
| 592 |
"DNS=10.10.10.11\n" |
| 593 |
"Bridge=bridge99\n" |
| 594 |
"\n[DHCP]\n" |
| 595 |
"Hostname=hogehoge\n" |
| 596 |
"\n[Address]\n" |
| 597 |
"Address=192.168.0.10/24\n" |
| 598 |
"Peer=192.168.0.2\n" |
| 599 |
"\n[Route]\n" |
| 600 |
"Gateway=192.168.0.1\n" |
| 601 |
); |
| 602 |
|
| 603 |
test_network_two("BOOTIF", |
| 604 |
"ip", "::::hogehoge:BOOTIF:dhcp", |
| 605 |
"BOOTIF", "01-00:11:22:33:44:55", |
| 606 |
"[Match]\n" |
| 607 |
"MACAddress=00:11:22:33:44:55\n" |
| 608 |
"\n[Link]\n" |
| 609 |
"\n[Network]\n" |
| 610 |
"DHCP=ipv4\n" |
| 611 |
"\n[DHCP]\n" |
| 612 |
"Hostname=hogehoge\n" |
| 613 |
); |
| 614 |
|
| 615 |
test_network_two("BOOTIF", |
| 616 |
"ip", "::::hogehoge:BOOTIF:dhcp", |
| 617 |
"BOOTIF", "00:11:22:33:44:55", |
| 618 |
"[Match]\n" |
| 619 |
"MACAddress=00:11:22:33:44:55\n" |
| 620 |
"\n[Link]\n" |
| 621 |
"\n[Network]\n" |
| 622 |
"DHCP=ipv4\n" |
| 623 |
"\n[DHCP]\n" |
| 624 |
"Hostname=hogehoge\n" |
| 625 |
); |
| 626 |
|
| 627 |
test_network_two("BOOTIF", |
| 628 |
"ip", "::::hogehoge:BOOTIF:dhcp", |
| 629 |
"BOOTIF", "01-00-11-22-33-44-55", |
| 630 |
"[Match]\n" |
| 631 |
"MACAddress=00:11:22:33:44:55\n" |
| 632 |
"\n[Link]\n" |
| 633 |
"\n[Network]\n" |
| 634 |
"DHCP=ipv4\n" |
| 635 |
"\n[DHCP]\n" |
| 636 |
"Hostname=hogehoge\n" |
| 637 |
); |
| 638 |
|
| 639 |
test_network_three("BOOTIF", |
| 640 |
"ip", "::::hogehoge:BOOTIF:dhcp", |
| 641 |
"BOOTIF", "01-00:11:22:33:44:55", |
| 642 |
"rd.bootif", "1", |
| 643 |
"[Match]\n" |
| 644 |
"MACAddress=00:11:22:33:44:55\n" |
| 645 |
"\n[Link]\n" |
| 646 |
"\n[Network]\n" |
| 647 |
"DHCP=ipv4\n" |
| 648 |
"\n[DHCP]\n" |
| 649 |
"Hostname=hogehoge\n" |
| 650 |
); |
| 651 |
|
| 652 |
test_network_three("BOOTIF", |
| 653 |
"ip", "::::hogehoge:BOOTIF:dhcp", |
| 654 |
"BOOTIF", "01-00:11:22:33:44:55", |
| 655 |
"rd.bootif", "0", |
| 656 |
NULL |
| 657 |
); |
| 658 |
|
| 659 |
return 0; |
| 660 |
} |