Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Network Manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Automate
Agent sessions
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
network
Network Manager
Commits
cc1c8b38
Commit
cc1c8b38
authored
Aug 29, 2024
by
Amin Ben Romdhane
Browse files
Options
Downloads
Patches
Plain Diff
IP.ActivePort: Stop browsing when a specific instance is required
parent
775bd689
No related branches found
No related tags found
1 merge request
!2
IP.ActivePort: Stop browsing when a specific instance is required
Pipeline
#168196
passed
Aug 30, 2024
Stage: static_code_analysis
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ip.c
+17
-8
17 additions, 8 deletions
src/ip.c
with
17 additions
and
8 deletions
src/ip.c
+
17
−
8
View file @
cc1c8b38
...
@@ -68,14 +68,16 @@ static void parse_tcp_line(const char* line, int is_ipv6, ActivePort* port)
...
@@ -68,14 +68,16 @@ static void parse_tcp_line(const char* line, int is_ipv6, ActivePort* port)
port
->
state
=
state
;
port
->
state
=
state
;
}
}
static
void
browse_ip_port
(
struct
dmctx
*
dmctx
,
DMNODE
*
parent_node
,
bool
is_ipv6
,
const
char
*
proc_path
,
int
*
id
,
char
*
inst
)
static
bool
browse_ip_port
(
struct
dmctx
*
dmctx
,
DMNODE
*
parent_node
,
bool
is_ipv6
,
const
char
*
proc_path
,
int
*
id
)
{
{
bool
is_instance
=
false
;
if
(
proc_path
==
NULL
||
DM_STRLEN
(
proc_path
)
==
0
)
if
(
proc_path
==
NULL
||
DM_STRLEN
(
proc_path
)
==
0
)
return
;
return
is_instance
;
FILE
*
fp
=
fopen
(
proc_path
,
"r"
);
FILE
*
fp
=
fopen
(
proc_path
,
"r"
);
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
return
;
return
is_instance
;
}
}
char
line
[
256
]
=
{
0
};
char
line
[
256
]
=
{
0
};
...
@@ -93,13 +95,17 @@ static void browse_ip_port(struct dmctx *dmctx, DMNODE *parent_node, bool is_ipv
...
@@ -93,13 +95,17 @@ static void browse_ip_port(struct dmctx *dmctx, DMNODE *parent_node, bool is_ipv
continue
;
continue
;
curr_data
.
additional_data
=
(
void
*
)(
&
port
);
curr_data
.
additional_data
=
(
void
*
)(
&
port
);
inst
=
handle_instance_without_section
(
dmctx
,
parent_node
,
++
(
*
id
));
char
*
inst
=
handle_instance_without_section
(
dmctx
,
parent_node
,
++
(
*
id
));
if
(
DM_LINK_INST_OBJ
(
dmctx
,
parent_node
,
(
void
*
)
&
curr_data
,
inst
)
==
DM_STOP
)
if
(
DM_LINK_INST_OBJ
(
dmctx
,
parent_node
,
(
void
*
)
&
curr_data
,
inst
)
==
DM_STOP
)
{
is_instance
=
true
;
break
;
break
;
}
}
}
fclose
(
fp
);
fclose
(
fp
);
return
is_instance
;
}
}
static
int
init_interface_ip_args
(
struct
dm_data
*
args
,
struct
uci_section
*
iface_sec
,
struct
uci_section
*
dmmap_sec
,
json_object
*
json_obj
)
static
int
init_interface_ip_args
(
struct
dm_data
*
args
,
struct
uci_section
*
iface_sec
,
struct
uci_section
*
dmmap_sec
,
json_object
*
json_obj
)
...
@@ -899,11 +905,14 @@ end:
...
@@ -899,11 +905,14 @@ end:
static
int
browseIPActivePortInst
(
struct
dmctx
*
dmctx
,
DMNODE
*
parent_node
,
void
*
prev_data
,
char
*
prev_instance
)
static
int
browseIPActivePortInst
(
struct
dmctx
*
dmctx
,
DMNODE
*
parent_node
,
void
*
prev_data
,
char
*
prev_instance
)
{
{
char
*
inst
=
NULL
;
bool
is_instance
=
false
;
int
id
=
0
;
int
id
=
0
;
browse_ip_port
(
dmctx
,
parent_node
,
0
,
"/proc/net/tcp"
,
&
id
,
inst
);
is_instance
=
browse_ip_port
(
dmctx
,
parent_node
,
0
,
"/proc/net/tcp"
,
&
id
);
browse_ip_port
(
dmctx
,
parent_node
,
1
,
"/proc/net/tcp6"
,
&
id
,
inst
);
if
(
is_instance
)
return
0
;
browse_ip_port
(
dmctx
,
parent_node
,
1
,
"/proc/net/tcp6"
,
&
id
);
return
0
;
return
0
;
}
}
...
...
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
sign in
to comment