Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Host Manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
network
Host Manager
Commits
e8216213
Commit
e8216213
authored
1 year ago
by
Anjan Chanda
Browse files
Options
Downloads
Patches
Plain Diff
set primary ipv4 address correctly in static ip case
parent
c07a0a37
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#101605
passed
1 year ago
Stage: static_code_analysis
Stage: compile_test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/hostmngr.c
+2
-0
2 additions, 0 deletions
src/hostmngr.c
src/neigh.c
+6
-0
6 additions, 0 deletions
src/neigh.c
src/neigh.h
+1
-0
1 addition, 0 deletions
src/neigh.h
src/ubus.c
+6
-2
6 additions, 2 deletions
src/ubus.c
with
15 additions
and
2 deletions
src/hostmngr.c
+
2
−
0
View file @
e8216213
...
...
@@ -350,6 +350,7 @@ void topology_update_hostname_of_neighbors(struct topologyd_private *priv,
inet_aton
(
h
->
ipv4
,
&
e
->
ipv4
.
addr
.
ip4
);
e
->
ipv4
.
family
=
AF_INET
;
e
->
leasetime
=
h
->
leasetime
;
e
->
ipv4_type_dhcp
=
1
;
ipn
=
neigh_ip_entry_lookup2
(
priv
,
&
e
->
ipv4
);
if
(
ipn
)
{
...
...
@@ -396,6 +397,7 @@ int topology_get_neigh_hostname(struct neigh_queue *q, uint8_t *macaddr)
inet_aton
(
h
->
ipv4
,
&
e
->
ipv4
.
addr
.
ip4
);
e
->
ipv4
.
family
=
AF_INET
;
e
->
leasetime
=
h
->
leasetime
;
e
->
ipv4_type_dhcp
=
1
;
ipn
=
neigh_ip_entry_lookup2
(
priv
,
&
e
->
ipv4
);
if
(
ipn
)
{
...
...
This diff is collapsed.
Click to expand it.
src/neigh.c
+
6
−
0
View file @
e8216213
...
...
@@ -835,6 +835,9 @@ struct neigh_entry *neigh_enqueue(void *nq, uint8_t *macaddr, uint16_t state,
}
if
(
ip
)
{
/* can get overridden by dhcp lease entry */
memcpy
(
&
e
->
ipv4
,
ip
,
sizeof
(
*
ip
));
list_for_each_entry
(
ipaddr
,
&
e
->
iplist
,
list
)
{
if
(
ipaddr_equal
(
&
ipaddr
->
ip
,
ip
))
ipknown
=
true
;
...
...
@@ -908,6 +911,9 @@ struct neigh_entry *neigh_enqueue(void *nq, uint8_t *macaddr, uint16_t state,
}
if
(
ip
)
{
/* can get overridden by dhcp lease entry */
memcpy
(
&
e
->
ipv4
,
ip
,
sizeof
(
*
ip
));
list_for_each_entry
(
ipaddr
,
&
e
->
iplist
,
list
)
{
if
(
ipaddr_equal
(
&
ipaddr
->
ip
,
ip
))
ipknown
=
true
;
...
...
This diff is collapsed.
Click to expand it.
src/neigh.h
+
1
−
0
View file @
e8216213
...
...
@@ -63,6 +63,7 @@ struct neigh_entry {
void
*
cookie
;
char
hostname
[
256
];
struct
ip_address
ipv4
;
/* from dhcp-lease table or neigh cache */
int
ipv4_type_dhcp
;
/* set 1 when dhcp assigned ipv4 address */
unsigned
long
leasetime
;
/* lease time() end if dhcp addresses */
struct
list_head
iplist
;
/* list of struct ip_address_entry */
struct
hlist_node
hlist
;
...
...
This diff is collapsed.
Click to expand it.
src/ubus.c
+
6
−
2
View file @
e8216213
...
...
@@ -359,7 +359,7 @@ int topologyd_ubus_show_hosts(struct ubus_context *ctx, struct ubus_object *obj,
hlist_for_each_entry
(
e
,
&
q
->
table
[
i
],
hlist
)
{
struct
ip_address_entry
*
ipv4
,
*
ipv6
;
unsigned
long
leasetime_rem
;
long
leasetime_rem
;
char
statestr
[
128
]
=
{
0
};
char
ip4buf
[
32
]
=
{
0
};
char
*
ifname
=
NULL
;
...
...
@@ -378,7 +378,11 @@ int topologyd_ubus_show_hosts(struct ubus_context *ctx, struct ubus_object *obj,
inet_ntop
(
e
->
ipv4
.
family
,
&
e
->
ipv4
.
addr
,
ip4buf
,
sizeof
(
ip4buf
));
blobmsg_add_string
(
&
bb
,
"ipv4addr"
,
ip4buf
);
leasetime_rem
=
e
->
leasetime
?
e
->
leasetime
-
(
unsigned
long
)
time
(
NULL
)
:
0
;
blobmsg_add_string
(
&
bb
,
"address_source"
,
leasetime_rem
?
"DHCP"
:
"Static"
);
if
(
leasetime_rem
<
0
)
{
leasetime_rem
=
0
;
topology_get_neigh_hostname
(
q
,
e
->
macaddr
);
//TODO: move to inotify cb
}
blobmsg_add_string
(
&
bb
,
"address_source"
,
e
->
ipv4_type_dhcp
?
"DHCP"
:
"Static"
);
blobmsg_add_u32
(
&
bb
,
"lease_time_remaining"
,
leasetime_rem
);
blobmsg_add_u8
(
&
bb
,
"iswifi"
,
e
->
type
==
NEIGH_TYPE_WIFI
?
true
:
false
);
blobmsg_add_u8
(
&
bb
,
"is1905"
,
e
->
is1905
?
true
:
false
);
...
...
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