Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
f4grx
NuttX RTOS
Commits
c76774cf
Commit
c76774cf
authored
7 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
net/route: Add logic to mark a route as most-recently-used in the route cache.
parent
c3bd4fd1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
net/route/net_router.c
+42
-60
42 additions, 60 deletions
net/route/net_router.c
net/route/netdev_router.c
+50
-59
50 additions, 59 deletions
net/route/netdev_router.c
with
92 additions
and
119 deletions
net/route/net_router.c
+
42
−
60
View file @
c76774cf
...
...
@@ -230,48 +230,39 @@ int net_ipv4_router(in_addr_t target, FAR in_addr_t *router)
/* First see if we can find a router entry in the cache */
ret
=
net_foreachcache_ipv4
(
net_ipv4_match
,
&
match
);
if
(
ret
>
0
)
if
(
ret
<=
0
)
#endif
{
/* We found a route. Return the router address.
*
* REVISIT: We should move the cache entry to the head of the list
* because it is the most recently used.
/* Not found in the cache. Try to find a router entry with the
* routing table that can forward to this address
*/
net_ipv4addr_copy
(
*
router
,
match
.
IPv4_ROUTER
);
ret
=
OK
;
ret
=
net_foreachroute_ipv4
(
net_ipv4_match
,
&
match
);
}
else
#endif
/* Did we find a route? */
if
(
ret
<=
0
)
{
/* Find a router entry with the routing table that can forward to this
* address
*/
/* No.. there is no route for this address */
ret
=
net_foreachroute_ipv4
(
net_ipv4_match
,
&
match
)
;
if
(
ret
>
0
)
{
/* We found a route. */
ret
urn
-
ENOENT
;
}
/* We found a route. */
#ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
/* Add the route to the cache */
/* Add the route to the cache. If the route is already in the cache, this
* will update it to the most recently accessed.
*/
ret
=
net_addcache_ipv4
(
&
match
.
entry
);
(
void
)
net_addcache_ipv4
(
&
match
.
entry
);
#endif
/* Return the router address. */
net_ipv4addr_copy
(
*
router
,
match
.
IPv4_ROUTER
);
ret
=
OK
;
}
else
{
/* There is no route for this address */
/* Return the router address. */
ret
=
-
ENOENT
;
}
}
return
ret
;
net_ipv4addr_copy
(
*
router
,
match
.
IPv4_ROUTER
);
return
OK
;
}
#endif
/* CONFIG_NET_IPv4 */
...
...
@@ -314,48 +305,39 @@ int net_ipv6_router(const net_ipv6addr_t target, net_ipv6addr_t router)
/* First see if we can find a router entry in the cache */
ret
=
net_foreachcache_ipv6
(
net_ipv6_match
,
&
match
);
if
(
ret
>
0
)
if
(
ret
<=
0
)
#endif
{
/* We found a route. Return the router address.
*
* REVISIT: We should move the cache entry to the head of the list
* because it is the most recently used.
/* Not found in the cache. Try to find a router entry with the
* routing table that can forward to this address
*/
net_ipv6addr_copy
(
router
,
match
.
IPv6_ROUTER
);
ret
=
OK
;
ret
=
net_foreachroute_ipv6
(
net_ipv6_match
,
&
match
);
}
else
#endif
/* Did we find a route? */
if
(
ret
<=
0
)
{
/* Find n router entry with the routing table that can forward to this
* address
*/
/* No.. there is no route for this address */
ret
=
net_foreachroute_ipv6
(
net_ipv6_match
,
&
match
)
;
if
(
ret
>
0
)
{
/* We found a route */
ret
urn
-
ENOENT
;
}
/* We found a route
.
*/
#ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
/* Add the route to the cache */
/* Add the route to the cache. If the route is already in the cache, this
* will update it to the most recently accessed.
*/
ret
=
net_addcache_ipv6
(
&
match
.
entry
);
(
void
)
net_addcache_ipv6
(
&
match
.
entry
);
#endif
/* Return the router address. */
net_ipv6addr_copy
(
router
,
match
.
IPv6_ROUTER
);
ret
=
OK
;
}
else
{
/* There is no route for this address */
ret
=
-
ENOENT
;
}
}
/* Return the router address. */
return
ret
;
net_ipv6addr_copy
(
router
,
match
.
IPv6_ROUTER
);
return
OK
;
}
#endif
/* CONFIG_NET_IPv6 */
...
...
This diff is collapsed.
Click to expand it.
net/route/netdev_router.c
+
50
−
59
View file @
c76774cf
...
...
@@ -243,46 +243,42 @@ void netdev_ipv4_router(FAR struct net_driver_s *dev, in_addr_t target,
/* First see if we can find a router entry in the cache */
ret
=
net_foreachcache_ipv4
(
net_ipv4_devmatch
,
&
match
);
if
(
ret
<=
0
)
#endif
{
/* Not found in the cache. Try to find a router entry with the
* routing table that can forward to this address
*/
ret
=
net_foreachroute_ipv4
(
net_ipv4_devmatch
,
&
match
);
}
/* Did we find a route? */
if
(
ret
>
0
)
{
/* We found a route. Return the router address.
*
* REVISIT: We should move the cache entry to the head of the list
* because it is the most recently used.
/* We found a route. */
#ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
/* Add the route to the cache. If the route is already in the cache,
* this will update it to the most recently accessed.
*/
ret
=
net_addcache_ipv4
(
&
match
.
entry
);
#endif
/* We Return the router address. */
net_ipv4addr_copy
(
*
router
,
match
.
IPv4_ROUTER
);
}
else
#endif
{
/* Find a router entry with the routing table that can forward to this
* address using this device.
/* There isn't a matching route.. fallback and use the default
* router
* of the device.
*/
ret
=
net_foreachroute_ipv4
(
net_ipv4_devmatch
,
&
match
);
if
(
ret
>
0
)
{
/* We found a route */
#ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
/* Add the route to the cache */
ret
=
net_addcache_ipv4
(
&
match
.
entry
);
#endif
/* We Return the router address. */
net_ipv4addr_copy
(
*
router
,
match
.
IPv4_ROUTER
);
}
else
{
/* There isn't a matching route.. fallback and use the default
* router
* of the device.
*/
net_ipv4addr_copy
(
*
router
,
dev
->
d_draddr
);
}
net_ipv4addr_copy
(
*
router
,
dev
->
d_draddr
);
}
}
#endif
...
...
@@ -326,45 +322,40 @@ void netdev_ipv6_router(FAR struct net_driver_s *dev,
/* First see if we can find a router entry in the cache */
ret
=
net_foreachcache_ipv6
(
net_ipv6_devmatch
,
&
match
);
if
(
ret
<=
0
)
#endif
{
/* Not found in the cache. Try to find a router entry with the
* routing table that can forward to this address
*/
ret
=
net_foreachroute_ipv6
(
net_ipv6_devmatch
,
&
match
);
}
/* Did we find a route? */
if
(
ret
>
0
)
{
/* We found a route. Return the router address.
*
* REVISIT: We should move the cache entry to the head of the list
* because it is the most recently used.
/* We found a route. */
#ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
/* Add the route to the cache. If the route is already in the cache,
* this will update it to the most recently accessed.
*/
ret
=
net_addcache_ipv6
(
&
match
.
entry
);
#endif
/* Return the router address. */
net_ipv6addr_copy
(
router
,
match
.
IPv6_ROUTER
);
}
else
#endif
{
/*
Find a router entry with the routing table that can forward to this
*
address using
th
is
device.
/*
There isn't a matching route.. fallback and use the default
*
router of
th
e
device.
*/
ret
=
net_foreachroute_ipv6
(
net_ipv6_devmatch
,
&
match
);
if
(
ret
>
0
)
{
/* We found a route */
#ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
/* Add the route to the cache */
ret
=
net_addcache_ipv6
(
&
match
.
entry
);
#endif
/* Return the router address. */
net_ipv6addr_copy
(
router
,
match
.
IPv6_ROUTER
);
}
else
{
/* There isn't a matching route.. fallback and use the default
* router of the device.
*/
net_ipv6addr_copy
(
router
,
dev
->
d_ipv6draddr
);
}
net_ipv6addr_copy
(
router
,
dev
->
d_ipv6draddr
);
}
}
#endif
...
...
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