Commit bf1db8ec authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Rework v4-via-v6 configuration.

We now accept v4-via-v6 routes if the kernel supports installing
them, and announce them if the kernel is able to source ICMPv4
without an IPv4 address.  The latter behaviour is configurable,
the former is not.
parent 33462073
...@@ -63,7 +63,7 @@ int debug = 0; ...@@ -63,7 +63,7 @@ int debug = 0;
int link_detect = 0; int link_detect = 0;
int all_wireless = 0; int all_wireless = 0;
int has_ipv6_subtrees = 0; int has_ipv6_subtrees = 0;
int has_v4viav6 = 0; int has_v4viav6 = 0, safe_v4viav6 = 0;
int default_wireless_hello_interval = -1; int default_wireless_hello_interval = -1;
int default_wired_hello_interval = -1; int default_wired_hello_interval = -1;
int resend_delay = -1; int resend_delay = -1;
...@@ -153,6 +153,7 @@ main(int argc, char **argv) ...@@ -153,6 +153,7 @@ main(int argc, char **argv)
change_smoothing_half_life(4); change_smoothing_half_life(4);
has_ipv6_subtrees = kernel_has_ipv6_subtrees(); has_ipv6_subtrees = kernel_has_ipv6_subtrees();
has_v4viav6 = kernel_has_v4viav6(); has_v4viav6 = kernel_has_v4viav6();
safe_v4viav6 = kernel_safe_v4viav6();
while(1) { while(1) {
opt = getopt(argc, argv, opt = getopt(argc, argv,
......
...@@ -200,11 +200,6 @@ This specifies whether to use native source-specific IPv6 forwarding ...@@ -200,11 +200,6 @@ This specifies whether to use native source-specific IPv6 forwarding
rather than multiple routing tables. The default is chosen automatically rather than multiple routing tables. The default is chosen automatically
depending on the kernel version. depending on the kernel version.
.TP .TP
.BR v4-over-v6 " {" true | false }
This specifies whether to use v4-over-v6 routes (IPv4 routes with an IPv6
next-hop). This should not be enabled unless your kernel supports it. The
default is chosen automatically depending on the kernel version.
.TP
.BI debug " level" .BI debug " level"
This specifies the debugging level, and is equivalent to the command-line This specifies the debugging level, and is equivalent to the command-line
option option
...@@ -470,6 +465,10 @@ and ...@@ -470,6 +465,10 @@ and
.BR 0 .BR 0
otherwise. otherwise.
.TP .TP
.B$ v4-via-v6 " {" true | false }
Whether to announce IPv4 routes through this interface even when there is
no IPv4 address. The default depends on the kernel version.
.TP
.BI key " id" .BI key " id"
Enable HMAC security on this interface, and use the key Enable HMAC security on this interface, and use the key
.IR id . .IR id .
......
...@@ -700,6 +700,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure, ...@@ -700,6 +700,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if(c < -1) if(c < -1)
goto error; goto error;
if_conf->accept_bad_signatures = v; if_conf->accept_bad_signatures = v;
} else if(strcmp(token, "v4-via-v6") == 0) {
int v;
c = getbool(c, &v, gnc, closure);
if(c < -1)
goto error;
if_conf->v4viav6 = v;
} else { } else {
goto error; goto error;
} }
...@@ -917,6 +923,7 @@ merge_ifconf(struct interface_conf *dest, ...@@ -917,6 +923,7 @@ merge_ifconf(struct interface_conf *dest,
MERGE(rtt_min); MERGE(rtt_min);
MERGE(rtt_max); MERGE(rtt_max);
MERGE(max_rtt_penalty); MERGE(max_rtt_penalty);
MERGE(v4viav6);
MERGE(key); MERGE(key);
#undef MERGE #undef MERGE
...@@ -1029,7 +1036,6 @@ parse_option(int c, gnc_t gnc, void *closure, char *token) ...@@ -1029,7 +1036,6 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
strcmp(token, "daemonise") == 0 || strcmp(token, "daemonise") == 0 ||
strcmp(token, "skip-kernel-setup") == 0 || strcmp(token, "skip-kernel-setup") == 0 ||
strcmp(token, "ipv6-subtrees") == 0 || strcmp(token, "ipv6-subtrees") == 0 ||
strcmp(token, "v4-over-v6") == 0 ||
strcmp(token, "reflect-kernel-metric") == 0) { strcmp(token, "reflect-kernel-metric") == 0) {
int b; int b;
c = getbool(c, &b, gnc, closure); c = getbool(c, &b, gnc, closure);
...@@ -1046,8 +1052,6 @@ parse_option(int c, gnc_t gnc, void *closure, char *token) ...@@ -1046,8 +1052,6 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
skip_kernel_setup = b; skip_kernel_setup = b;
else if(strcmp(token, "ipv6-subtrees") == 0) else if(strcmp(token, "ipv6-subtrees") == 0)
has_ipv6_subtrees = b; has_ipv6_subtrees = b;
else if(strcmp(token, "v4-over-v6") == 0)
has_v4viav6 = b;
else if(strcmp(token, "reflect-kernel-metric") == 0) else if(strcmp(token, "reflect-kernel-metric") == 0)
reflect_kernel_metric = b; reflect_kernel_metric = b;
else else
......
...@@ -280,6 +280,7 @@ interface_updown(struct interface *ifp, int up) ...@@ -280,6 +280,7 @@ interface_updown(struct interface *ifp, int up)
{ {
int mtu, rc, type; int mtu, rc, type;
struct ipv6_mreq mreq; struct ipv6_mreq mreq;
int v4viav6;
if((!!up) == if_up(ifp)) if((!!up) == if_up(ifp))
return 0; return 0;
...@@ -458,6 +459,17 @@ interface_updown(struct interface *ifp, int up) ...@@ -458,6 +459,17 @@ interface_updown(struct interface *ifp, int up)
else else
ifp->flags &= ~IF_RFC6126; ifp->flags &= ~IF_RFC6126;
if(IF_CONF(ifp, v4viav6) == CONFIG_NO)
v4viav6 = 0;
else if(IF_CONF(ifp, v4viav6 == CONFIG_YES))
v4viav6 = 1;
else
v4viav6 = kernel_safe_v4viav6();
if(v4viav6)
ifp->flags |= IF_V4VIAV6;
else
ifp->flags &= ~IF_V4VIAV6;
rc = check_link_local_addresses(ifp); rc = check_link_local_addresses(ifp);
if(rc < 0) { if(rc < 0) {
goto fail; goto fail;
......
...@@ -56,6 +56,7 @@ struct interface_conf { ...@@ -56,6 +56,7 @@ struct interface_conf {
char enable_timestamps; char enable_timestamps;
char rfc6126; char rfc6126;
char accept_bad_signatures; char accept_bad_signatures;
char v4viav6;
int channel; int channel;
unsigned int rtt_decay; unsigned int rtt_decay;
unsigned int rtt_min; unsigned int rtt_min;
...@@ -89,6 +90,8 @@ struct interface_conf { ...@@ -89,6 +90,8 @@ struct interface_conf {
#define IF_ACCEPT_BAD_SIGNATURES (1 << 8) #define IF_ACCEPT_BAD_SIGNATURES (1 << 8)
/* Use Babel over DTLS on this interface. */ /* Use Babel over DTLS on this interface. */
#define IF_DTLS (1 << 9) #define IF_DTLS (1 << 9)
/* Announce v4-via-v6 routes through this interface. */
#define IF_V4VIAV6 (1 << 10)
/* Only INTERFERING can appear on the wire. */ /* Only INTERFERING can appear on the wire. */
#define IF_CHANNEL_UNKNOWN 0 #define IF_CHANNEL_UNKNOWN 0
......
...@@ -96,6 +96,7 @@ int read_random_bytes(void *buf, int len); ...@@ -96,6 +96,7 @@ int read_random_bytes(void *buf, int len);
int kernel_older_than(const char *sysname, int version, int sub_version); int kernel_older_than(const char *sysname, int version, int sub_version);
int kernel_has_ipv6_subtrees(void); int kernel_has_ipv6_subtrees(void);
int kernel_has_v4viav6(void); int kernel_has_v4viav6(void);
int kernel_safe_v4viav6(void);
int add_rule(int prio, const unsigned char *src_prefix, int src_plen, int add_rule(int prio, const unsigned char *src_prefix, int src_plen,
int table); int table);
int flush_rule(int prio, int family); int flush_rule(int prio, int family);
......
...@@ -951,6 +951,13 @@ kernel_has_v4viav6(void) ...@@ -951,6 +951,13 @@ kernel_has_v4viav6(void)
return (kernel_older_than("Linux", 5, 2) == 0); return (kernel_older_than("Linux", 5, 2) == 0);
} }
/* Whether the kernel is able to source ICMPv4 without an IPv4 address. */
int
kernel_safe_v4viav6(void)
{
return (kernel_older_than("Linux", 5, 13) == 0);
}
int int
kernel_route(int operation, int table, kernel_route(int operation, int table,
const unsigned char *dest, unsigned short plen, const unsigned char *dest, unsigned short plen,
......
...@@ -401,6 +401,12 @@ kernel_has_v4viav6(void) ...@@ -401,6 +401,12 @@ kernel_has_v4viav6(void)
return 0; return 0;
} }
int
kernel_safe_v4viav6(void)
{
return 0;
}
int int
kernel_route(int operation, int table, kernel_route(int operation, int table,
const unsigned char *dest, unsigned short plen, const unsigned char *dest, unsigned short plen,
......
...@@ -1461,6 +1461,8 @@ really_buffer_update(struct buffered *buf, struct interface *ifp, ...@@ -1461,6 +1461,8 @@ really_buffer_update(struct buffered *buf, struct interface *ifp,
if(v4) { if(v4) {
if(!ifp->ipv4) { if(!ifp->ipv4) {
if((ifp->flags & IF_V4VIAV6) == 0)
return;
ae = AE_V4VIAV6; ae = AE_V4VIAV6;
} else { } else {
ae = AE_IPV4; ae = AE_IPV4;
......
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