Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
a4fab982
Commit
a4fab982
authored
6 years ago
by
cedi
Browse files
Options
Downloads
Patches
Plain Diff
Write multiple next hops to netlink in case there are multiple ones
parent
d832d540
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
protocols/netlink/netlink_writer.go
+19
-7
19 additions, 7 deletions
protocols/netlink/netlink_writer.go
with
19 additions
and
7 deletions
protocols/netlink/netlink_writer.go
+
19
−
7
View file @
a4fab982
...
@@ -131,14 +131,17 @@ func (nw *NetlinkWriter) RemovePath(pfx bnet.Prefix, path *route.Path) bool {
...
@@ -131,14 +131,17 @@ func (nw *NetlinkWriter) RemovePath(pfx bnet.Prefix, path *route.Path) bool {
// Add pfx/path to kernel
// Add pfx/path to kernel
func
(
nw
*
NetlinkWriter
)
addKernel
(
pfx
bnet
.
Prefix
)
error
{
func
(
nw
*
NetlinkWriter
)
addKernel
(
pfx
bnet
.
Prefix
)
error
{
route
:=
nw
.
createRoute
(
pfx
,
nw
.
pathTable
[
pfx
])
route
,
err
:=
nw
.
createRoute
(
pfx
,
nw
.
pathTable
[
pfx
])
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Could not create Route: %v"
,
err
.
Error
())
}
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"Prefix"
:
pfx
.
String
(),
"Prefix"
:
pfx
.
String
(),
"Table"
:
route
.
Table
,
"Table"
:
route
.
Table
,
})
.
Debug
(
"AddPath to netlink"
)
})
.
Debug
(
"AddPath to netlink"
)
err
:
=
netlink
.
RouteAdd
(
route
)
err
=
netlink
.
RouteAdd
(
route
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorf
(
"Error while adding route: %v"
,
err
)
log
.
Errorf
(
"Error while adding route: %v"
,
err
)
return
fmt
.
Errorf
(
"Error while adding route: %v"
,
err
)
return
fmt
.
Errorf
(
"Error while adding route: %v"
,
err
)
...
@@ -149,13 +152,16 @@ func (nw *NetlinkWriter) addKernel(pfx bnet.Prefix) error {
...
@@ -149,13 +152,16 @@ func (nw *NetlinkWriter) addKernel(pfx bnet.Prefix) error {
// remove pfx/path from kernel
// remove pfx/path from kernel
func
(
nw
*
NetlinkWriter
)
removeKernel
(
pfx
bnet
.
Prefix
,
paths
[]
*
route
.
Path
)
error
{
func
(
nw
*
NetlinkWriter
)
removeKernel
(
pfx
bnet
.
Prefix
,
paths
[]
*
route
.
Path
)
error
{
route
:=
nw
.
createRoute
(
pfx
,
nw
.
pathTable
[
pfx
])
route
,
err
:=
nw
.
createRoute
(
pfx
,
nw
.
pathTable
[
pfx
])
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Could not create Route: %v"
,
err
.
Error
())
}
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
"Prefix"
:
pfx
.
String
(),
"Prefix"
:
pfx
.
String
(),
})
.
Debug
(
"Remove from netlink"
)
})
.
Debug
(
"Remove from netlink"
)
err
:
=
netlink
.
RouteDel
(
route
)
err
=
netlink
.
RouteDel
(
route
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error while removing route: %v"
,
err
)
return
fmt
.
Errorf
(
"Error while removing route: %v"
,
err
)
}
}
...
@@ -164,7 +170,7 @@ func (nw *NetlinkWriter) removeKernel(pfx bnet.Prefix, paths []*route.Path) erro
...
@@ -164,7 +170,7 @@ func (nw *NetlinkWriter) removeKernel(pfx bnet.Prefix, paths []*route.Path) erro
}
}
// create a route from a prefix and a path
// create a route from a prefix and a path
func
(
nw
*
NetlinkWriter
)
createRoute
(
pfx
bnet
.
Prefix
,
paths
[]
*
route
.
Path
)
*
netlink
.
Route
{
func
(
nw
*
NetlinkWriter
)
createRoute
(
pfx
bnet
.
Prefix
,
paths
[]
*
route
.
Path
)
(
*
netlink
.
Route
,
error
)
{
route
:=
&
netlink
.
Route
{
route
:=
&
netlink
.
Route
{
Dst
:
pfx
.
GetIPNet
(),
Dst
:
pfx
.
GetIPNet
(),
Table
:
int
(
nw
.
options
.
RoutingTable
),
// config dependent
Table
:
int
(
nw
.
options
.
RoutingTable
),
// config dependent
...
@@ -180,7 +186,13 @@ func (nw *NetlinkWriter) createRoute(pfx bnet.Prefix, paths []*route.Path) *netl
...
@@ -180,7 +186,13 @@ func (nw *NetlinkWriter) createRoute(pfx bnet.Prefix, paths []*route.Path) *netl
multiPath
=
append
(
multiPath
,
nextHop
)
multiPath
=
append
(
multiPath
,
nextHop
)
}
}
route
.
MultiPath
=
multiPath
if
len
(
multiPath
)
==
1
{
route
.
Gw
=
multiPath
[
0
]
.
Gw
}
else
if
len
(
multiPath
)
>
1
{
route
.
MultiPath
=
multiPath
}
else
{
return
nil
,
fmt
.
Errorf
(
"No destination address specified. At least one NextHop has to be specified in path"
)
}
return
route
return
route
,
nil
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment