Commit 0ff8404d authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Determine default value of has_ipv6_subtrees dynamically.

Based on the kernel version, can be overridden explicitly.
parent 6d768ba4
...@@ -123,6 +123,7 @@ main(int argc, char **argv) ...@@ -123,6 +123,7 @@ main(int argc, char **argv)
parse_address("ff02:0:0:0:0:0:1:6", protocol_group, NULL); parse_address("ff02:0:0:0:0:0:1:6", protocol_group, NULL);
protocol_port = 6696; protocol_port = 6696;
change_smoothing_half_life(4); change_smoothing_half_life(4);
has_ipv6_subtrees = kernel_has_ipv6_subtrees();
while(1) { while(1) {
opt = getopt(argc, argv, "m:p:h:H:i:k:A:sruS:d:g:lwz:M:t:T:c:C:DL:I:"); opt = getopt(argc, argv, "m:p:h:H:i:k:A:sruS:d:g:lwz:M:t:T:c:C:DL:I:");
......
...@@ -190,13 +190,8 @@ equivalent to the command-line option ...@@ -190,13 +190,8 @@ equivalent to the command-line option
.TP .TP
.BR ipv6-subtrees " {" true | false } .BR ipv6-subtrees " {" true | false }
This specifies whether to use native source-specific IPv6 forwarding This specifies whether to use native source-specific IPv6 forwarding
rather than multiple routing tables. The default is rather than multiple routing tables. The default is chosen automatically
.BR false , depending on the kernel version.
setting this to
.B true
is recommended on sufficiently recent
.I Linux
kernels.
.TP .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
......
...@@ -20,6 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ...@@ -20,6 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
#include <sys/utsname.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/param.h> #include <sys/param.h>
#include <time.h> #include <time.h>
...@@ -109,3 +110,21 @@ add_import_table(int table) ...@@ -109,3 +110,21 @@ add_import_table(int table)
import_tables[import_table_count++] = table; import_tables[import_table_count++] = table;
return 0; return 0;
} }
int
kernel_older_than(const char *sysname, int version, int sub_version)
{
struct utsname un;
int rc;
int v = 0;
int sub_v = 0;
rc = uname(&un);
if (rc < 0)
return -1;
if (strcmp(sysname, un.sysname) != 0)
return -1;
rc = sscanf(un.release, "%d.%d", &v, &sub_v);
if (rc < 2)
return -1;
return (v < version || (v == version && sub_v < sub_version));
}
...@@ -78,3 +78,5 @@ int kernel_addresses(char *ifname, int ifindex, int ll, ...@@ -78,3 +78,5 @@ int kernel_addresses(char *ifname, int ifindex, int ll,
int if_eui64(char *ifname, int ifindex, unsigned char *eui); int if_eui64(char *ifname, int ifindex, unsigned char *eui);
int gettime(struct timeval *tv); int gettime(struct timeval *tv);
int read_random_bytes(void *buf, size_t len); int read_random_bytes(void *buf, size_t len);
int kernel_older_than(const char *sysname, int version, int sub_version);
int kernel_has_ipv6_subtrees(void);
...@@ -925,6 +925,12 @@ kernel_disambiguate(int v4) ...@@ -925,6 +925,12 @@ kernel_disambiguate(int v4)
return !v4 && has_ipv6_subtrees; return !v4 && has_ipv6_subtrees;
} }
int
kernel_has_ipv6_subtrees(void)
{
return (kernel_older_than("Linux", 3, 11) == 0);
}
int int
kernel_route(int operation, const unsigned char *dest, unsigned short plen, kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *src, unsigned short src_plen, const unsigned char *src, unsigned short src_plen,
......
...@@ -388,6 +388,12 @@ kernel_disambiguate(int v4) ...@@ -388,6 +388,12 @@ kernel_disambiguate(int v4)
return 0; return 0;
} }
int
kernel_has_ipv6_subtrees(void)
{
return 0;
}
int int
kernel_route(int operation, const unsigned char *dest, unsigned short plen, kernel_route(int operation, const unsigned char *dest, unsigned short plen,
const unsigned char *src, unsigned short src_plen, const unsigned char *src, unsigned short src_plen,
......
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