Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
snf-nfdhcpd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
snf-nfdhcpd
Commits
40a561a7
Commit
40a561a7
authored
Oct 03, 2012
by
Dimitris Aragiorgis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add handler for SIGUSR1 to show current state
Signed-off-by:
Dimitris Aragiorgis
<
dimara@grnet.gr
>
parent
2f5bfb6e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
9 deletions
+31
-9
nfdhcpd
nfdhcpd
+31
-9
No files found.
nfdhcpd
View file @
40a561a7
...
...
@@ -20,6 +20,8 @@
#
import
os
import
signal
import
errno
import
re
import
sys
import
glob
...
...
@@ -40,7 +42,7 @@ from lockfile import LockTimeout
import
IPy
import
socket
from
select
import
select
import
select
from
socket
import
AF_INET
,
AF_INET6
from
scapy.data
import
ETH_P_ALL
...
...
@@ -452,9 +454,7 @@ class VMNetProxy(object): # pylint: disable=R0902
for
path
in
glob
.
glob
(
os
.
path
.
join
(
self
.
data_path
,
"*"
)):
self
.
add_tap
(
path
)
logging
.
debug
(
"%15s %20s %7s %15s"
,
'Client'
,
'MAC'
,
'TAP'
,
'IP'
)
for
b
in
self
.
clients
.
values
():
logging
.
debug
(
"%15s %20s %7s %15s"
,
b
.
hostname
,
b
.
mac
,
b
.
tap
,
b
.
ip
)
self
.
print_clients
()
def
get_ifindex
(
self
,
iface
):
""" Get the interface index from sysfs
...
...
@@ -548,12 +548,12 @@ class VMNetProxy(object): # pylint: disable=R0902
"""
try
:
for
cl
in
self
.
clients
.
value
s
():
for
k
,
cl
in
self
.
clients
.
item
s
():
if
cl
.
tap
==
tap
:
logging
.
debug
(
"Removing client on interface %s"
,
tap
)
logging
.
debug
(
"
- %10s %20s %7s %15
s"
,
cl
.
hostname
,
cl
.
mac
,
cl
.
tap
,
cl
.
ip
)
del
cl
logging
.
debug
(
"
%10s | %10s %20s %10s %20
s"
,
k
,
cl
.
hostname
,
cl
.
mac
,
cl
.
tap
,
cl
.
ip
)
del
self
.
clients
[
k
]
except
:
logging
.
debug
(
"Client on %s disappeared!!!"
,
tap
)
...
...
@@ -874,7 +874,13 @@ class VMNetProxy(object): # pylint: disable=R0902
timeout
=
None
while
True
:
rlist
,
_
,
xlist
=
select
(
self
.
nfq
.
keys
()
+
[
iwfd
],
[],
[],
timeout
)
try
:
rlist
,
_
,
xlist
=
select
.
select
(
self
.
nfq
.
keys
()
+
[
iwfd
],
[],
[],
timeout
)
except
select
.
error
,
e
:
if
e
[
0
]
==
errno
.
EINTR
:
logging
.
debug
(
"select() got interrupted"
)
continue
if
xlist
:
logging
.
warn
(
"Warning: Exception on %s"
,
", "
.
join
([
str
(
fd
)
for
fd
in
xlist
]))
...
...
@@ -909,6 +915,12 @@ class VMNetProxy(object): # pylint: disable=R0902
self
.
send_periodic_ra
()
timeout
=
self
.
ra_period
-
(
time
.
time
()
-
start
)
def
print_clients
(
self
):
logging
.
info
(
"%10s %20s %20s %10s %20s"
,
'Key'
,
'Client'
,
'MAC'
,
'TAP'
,
'IP'
)
for
k
,
cl
in
self
.
clients
.
items
():
logging
.
info
(
"%10s | %20s %20s %10s %20s"
,
k
,
cl
.
hostname
,
cl
.
mac
,
cl
.
tap
,
cl
.
ip
)
if
__name__
==
"__main__"
:
import
capng
...
...
@@ -1068,6 +1080,16 @@ if __name__ == "__main__":
proxy
=
VMNetProxy
(
data_path
=
config
[
"general"
][
"datapath"
],
**
proxy_opts
)
logging
.
info
(
"Ready to serve requests"
)
def
handler
(
signum
,
frame
):
logging
.
debug
(
'Received SIGUSR1. Printing current proxy state...'
)
proxy
.
print_clients
()
# Set the signal handler for debuging clients
signal
.
signal
(
signal
.
SIGUSR1
,
handler
)
signal
.
siginterrupt
(
signal
.
SIGUSR1
,
False
)
try
:
proxy
.
serve
()
except
Exception
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment