Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
86fcf400
Commit
86fcf400
authored
Sep 16, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RTA_PREFSRC
parent
2631dff6
Pipeline
#297
skipped
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
23 deletions
+33
-23
babeld.c
babeld.c
+9
-1
kernel.h
kernel.h
+1
-0
kernel_netlink.c
kernel_netlink.c
+23
-22
No files found.
babeld.c
View file @
86fcf400
...
@@ -106,6 +106,7 @@ main(int argc, char **argv)
...
@@ -106,6 +106,7 @@ main(int argc, char **argv)
void
*
vrc
;
void
*
vrc
;
unsigned
int
seed
;
unsigned
int
seed
;
struct
interface
*
ifp
;
struct
interface
*
ifp
;
unsigned
char
*
addr
;
gettime
(
&
now
);
gettime
(
&
now
);
...
@@ -123,7 +124,7 @@ main(int argc, char **argv)
...
@@ -123,7 +124,7 @@ main(int argc, char **argv)
change_smoothing_half_life
(
4
);
change_smoothing_half_life
(
4
);
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:F"
);
opt
=
getopt
(
argc
,
argv
,
"m:p:h:H:i:k:A:sruS:d:g:lwz:M:t:T:c:C:DL:I:F
P:
"
);
if
(
opt
<
0
)
if
(
opt
<
0
)
break
;
break
;
...
@@ -256,6 +257,13 @@ main(int argc, char **argv)
...
@@ -256,6 +257,13 @@ main(int argc, char **argv)
case
'F'
:
case
'F'
:
setup
=
1
;
setup
=
1
;
break
;
break
;
case
'P'
:
addr
=
malloc
(
16
);
rc
=
parse_address
(
optarg
,
addr
,
&
i
);
if
(
rc
<
0
)
goto
usage
;
preferred_source
[
i
==
AF_INET
]
=
addr
;
break
;
default:
default:
goto
usage
;
goto
usage
;
}
}
...
...
kernel.h
View file @
86fcf400
...
@@ -43,6 +43,7 @@ struct kernel_route {
...
@@ -43,6 +43,7 @@ struct kernel_route {
#define CHANGE_ADDR (1 << 2)
#define CHANGE_ADDR (1 << 2)
extern
int
export_table
,
import_table
;
extern
int
export_table
,
import_table
;
extern
unsigned
char
*
preferred_source
[
2
];
int
kernel_setup
(
int
setup
);
int
kernel_setup
(
int
setup
);
int
kernel_setup_socket
(
int
setup
);
int
kernel_setup_socket
(
int
setup
);
...
...
kernel_netlink.c
View file @
86fcf400
...
@@ -52,6 +52,7 @@ THE SOFTWARE.
...
@@ -52,6 +52,7 @@ THE SOFTWARE.
#include "interface.h"
#include "interface.h"
int
export_table
=
-
1
,
import_table
=
-
1
;
int
export_table
=
-
1
,
import_table
=
-
1
;
unsigned
char
*
preferred_source
[
2
]
=
{
NULL
,
NULL
};
static
int
old_forwarding
=
-
1
;
static
int
old_forwarding
=
-
1
;
static
int
old_ipv4_forwarding
=
-
1
;
static
int
old_ipv4_forwarding
=
-
1
;
...
@@ -940,45 +941,45 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
...
@@ -940,45 +941,45 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
rta
=
RTM_RTA
(
rtm
);
rta
=
RTM_RTA
(
rtm
);
if
(
ipv4
)
{
#define ADD_IPARG(type, addr) \
rta
=
RTA_NEXT
(
rta
,
len
);
do if(ipv4) { \
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
struct
in_addr
));
rta = RTA_NEXT(rta, len); \
rta
->
rta_type
=
RTA_DST
;
rta->rta_len = RTA_LENGTH(sizeof(struct in_addr)); \
memcpy
(
RTA_DATA
(
rta
),
dest
+
12
,
sizeof
(
struct
in_addr
));
rta->rta_type = type; \
}
else
{
memcpy(RTA_DATA(rta), addr + 12, sizeof(struct in_addr)); \
rta
=
RTA_NEXT
(
rta
,
len
);
} else { \
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
struct
in6_addr
));
rta = RTA_NEXT(rta, len); \
rta
->
rta_type
=
RTA_DST
;
rta->rta_len = RTA_LENGTH(sizeof(struct in6_addr)); \
memcpy
(
RTA_DATA
(
rta
),
dest
,
sizeof
(
struct
in6_addr
));
rta->rta_type = type; \
}
memcpy(RTA_DATA(rta), addr, sizeof(struct in6_addr)); \
} while (0)
ADD_IPARG
(
RTA_DST
,
dest
);
rta
=
RTA_NEXT
(
rta
,
len
);
rta
=
RTA_NEXT
(
rta
,
len
);
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
int
));
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
int
));
rta
->
rta_type
=
RTA_PRIORITY
;
rta
->
rta_type
=
RTA_PRIORITY
;
if
(
metric
<
KERNEL_INFINITY
)
{
if
(
metric
<
KERNEL_INFINITY
)
{
unsigned
char
*
src
;
*
(
int
*
)
RTA_DATA
(
rta
)
=
metric
;
*
(
int
*
)
RTA_DATA
(
rta
)
=
metric
;
rta
=
RTA_NEXT
(
rta
,
len
);
rta
=
RTA_NEXT
(
rta
,
len
);
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
int
));
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
int
));
rta
->
rta_type
=
RTA_OIF
;
rta
->
rta_type
=
RTA_OIF
;
*
(
int
*
)
RTA_DATA
(
rta
)
=
ifindex
;
*
(
int
*
)
RTA_DATA
(
rta
)
=
ifindex
;
if
(
ipv4
)
{
ADD_IPARG
(
RTA_GATEWAY
,
gate
);
rta
=
RTA_NEXT
(
rta
,
len
);
src
=
preferred_source
[
ipv4
];
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
struct
in_addr
));
if
(
src
)
rta
->
rta_type
=
RTA_GATEWAY
;
ADD_IPARG
(
RTA_PREFSRC
,
src
);
memcpy
(
RTA_DATA
(
rta
),
gate
+
12
,
sizeof
(
struct
in_addr
));
}
else
{
rta
=
RTA_NEXT
(
rta
,
len
);
rta
->
rta_len
=
RTA_LENGTH
(
sizeof
(
struct
in6_addr
));
rta
->
rta_type
=
RTA_GATEWAY
;
memcpy
(
RTA_DATA
(
rta
),
gate
,
sizeof
(
struct
in6_addr
));
}
}
else
{
}
else
{
*
(
int
*
)
RTA_DATA
(
rta
)
=
-
1
;
*
(
int
*
)
RTA_DATA
(
rta
)
=
-
1
;
}
}
buf
.
nh
.
nlmsg_len
=
(
char
*
)
rta
+
rta
->
rta_len
-
buf
.
raw
;
buf
.
nh
.
nlmsg_len
=
(
char
*
)
rta
+
rta
->
rta_len
-
buf
.
raw
;
#undef ADD_IPARG
return
netlink_talk
(
&
buf
.
nh
);
return
netlink_talk
(
&
buf
.
nh
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment