Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gNMI Target
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
gNMI Target
Commits
0e965c83
Commit
0e965c83
authored
2 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
Switch to route replace in case the default route has to be adjusted
parent
96dd557d
No related branches found
No related tags found
4 merge requests
!17
Build basic ci
,
!10
Add simple modem support on linux through modemmanager
,
!8
General refactoring
,
!5
Draft: Add basic set support for ip/routing via gnmi
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
os_clients/ubuntu/supportedPaths.go
+39
-4
39 additions, 4 deletions
os_clients/ubuntu/supportedPaths.go
with
39 additions
and
4 deletions
os_clients/ubuntu/supportedPaths.go
+
39
−
4
View file @
0e965c83
...
...
@@ -104,6 +104,7 @@ func walkThroughConfig(config ygot.ValidatedGoStruct) error {
}
}
}
if
networkInstances
:=
conf
.
NetworkInstances
;
networkInstances
!=
nil
{
if
networkInstanceMap
:=
networkInstances
.
NetworkInstance
;
networkInstanceMap
!=
nil
{
for
_
,
networkInstance
:=
range
networkInstanceMap
{
...
...
@@ -117,6 +118,7 @@ func walkThroughConfig(config ygot.ValidatedGoStruct) error {
}
}
}
return
nil
}
...
...
@@ -153,6 +155,7 @@ func generateSubinterface(subintf *gnmitargetygot.OpenconfigInterfaces_Interface
if
len
(
errs
)
!=
0
{
return
fmt
.
Errorf
(
"encountered %v errors during address adding
\n
%v"
,
len
(
errs
),
errs
)
}
return
nil
}
...
...
@@ -175,12 +178,43 @@ func generateProtocol(protocol *gnmitargetygot.OpenconfigNetworkInstance_Network
return
err
}
nextHop
:=
net
.
ParseIP
(
hop
.
GetConfig
()
.
GetIndex
())
_
=
ipnet
nextHop
,
ok
:=
hop
.
GetConfig
()
.
GetNextHop
()
.
(
*
gnmitargetygot
.
OpenconfigNetworkInstance_NetworkInstances_NetworkInstance_Protocols_Protocol_StaticRoutes_Static_NextHops_NextHop_Config_NextHop_Union_String
)
if
!
ok
{
return
fmt
.
Errorf
(
"only string union is supported for nextHop"
)
}
nextHopParsed
:=
net
.
ParseIP
(
nextHop
.
String
)
if
nextHop
==
nil
{
return
fmt
.
Errorf
(
"failed parsing ip"
)
}
route
:=
&
netlink
.
Route
{
LinkIndex
:
link
.
Attrs
()
.
Index
,
Dst
:
ipnet
,
Gw
:
nextHopParsed
,
}
//if route.Dst != nil {
// fmt.Println("Route GW: ", route.Gw.String())
// fmt.Println("Route Src: ", route.Src.String())
// fmt.Println("Route Dst: ", route.Dst.String())
// err != netlink.RouteAdd(route)
route
:=
netlink
.
Route
{
LinkIndex
:
link
.
Attrs
()
.
Index
,
Dst
:
ipnet
,
Src
:
nextHop
}
netlink
.
RouteAdd
(
&
route
)
//}
fmt
.
Println
(
"Route GW: "
,
route
.
Gw
.
String
())
fmt
.
Println
(
"Route Src: "
,
route
.
Src
.
String
())
fmt
.
Println
(
"Route Dst: "
,
route
.
Dst
.
String
())
if
err
:=
netlink
.
RouteReplace
(
route
);
err
!=
nil
{
return
err
}
}
}
return
nil
}
...
...
@@ -190,8 +224,8 @@ func CIDRToIPNet(s string) (*net.IPNet, error) {
return
nil
,
err
}
ipnet
.
IP
=
ip
return
ipnet
,
nil
return
ipnet
,
nil
}
func
filterKeys
(
path
*
gnmi
.
Path
)
[]
map
[
string
]
string
{
...
...
@@ -201,5 +235,6 @@ func filterKeys(path *gnmi.Path) []map[string]string {
keyMap
=
append
(
keyMap
,
key
)
}
}
return
keyMap
}
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