From: Dimitris Aragiorgis Date: Tue, 18 Feb 2014 13:18:28 +0000 (+0200) Subject: Merge branch 'develop' X-Git-Tag: 0.12.2~1 X-Git-Url: https://code.grnet.gr/git/snf-nfdhcpd/commitdiff_plain/d9fdaebb8f526aae931cc2d723f8d2b3c2d653d8?hp=da8200c2d47cfcc24b54a2117633a5666fd316eb Merge branch 'develop' --- diff --git a/.gitignore b/.gitignore index 0681f56..f5311b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *~ .dir version.py +docs/_build diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..0d4cdff --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,153 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/nfdhcpd.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/nfdhcpd.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/nfdhcpd" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/nfdhcpd" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..87e2b15 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,242 @@ +# -*- coding: utf-8 -*- +# +# nfdhcpd documentation build configuration file, created by +# sphinx-quickstart on Mon Jan 20 18:25:17 2014. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'nfdhcpd' +copyright = u'2014, Dimitris Aragiorgis' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.12' +# The full version, including alpha/beta/rc tags. +release = '0.12.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'nfdhcpddoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'nfdhcpd.tex', u'nfdhcpd Documentation', + u'Dimitris Aragiorgis', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'nfdhcpd', u'nfdhcpd Documentation', + [u'Dimitris Aragiorgis'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'nfdhcpd', u'nfdhcpd Documentation', + u'Dimitris Aragiorgis', 'nfdhcpd', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..adf71ae --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,182 @@ +.. nfdhcpd documentation master file, created by + sphinx-quickstart on Mon Jan 20 18:25:17 2014. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to nfdhcpd's documentation! +=================================== + +nfdhcpd is a userspace server written in python and based on NFQUEUE [1]. The +administrator can enable processing of DHCP, NS, RS, DHCPv6 requests on +individual TAP interfaces by injecting nfdhcpd in the processing pipeline for +IP packets dynamically (by mangling the corresponding packet types and redirect +them to the appropriate nfqueue). + +The daemon runs on the host and is controlled by manipulating files under its +state directory. Creation of a new file under this directory ("binding file") +instructs the daemon to reply on the requests arriving on the specified TAP +interface. + +nfdhcpd vs. dnsmasq +------------------- + +a) The service can be activated dynamically, per-interface, by manipulating +iptables accordingly. There is no need to restart the daemon, or edit +(potentially read-only) configuration files, you only need to drop a file +containing the required info under /var/lib/nfdhcpd. + +b) There is no interference to existing DHCP servers listening to port +67. Everything happens directly via NFQUEUE. + +c) The host doesn't even need to have an IP address on the interfaces +where DHCP replies are served, making it invisible to the VMs. This +may be beneficial from a security perspective. Similarly, it doesn't +matter if the TAP interface is bridged or routed. + +d) Binding files provide a TAP-MAC mapping. In other words, requests coming +from unregistered TAP interfaces (without a binding file) are ignored, and +packet processing happens as if nfdhcpd didn't exist in the first place. +Requests coming from a registered device with but with different are considered +as snooping attempts and are dropped. + +e) nfdhcpd is written in pure Python and uses scapy for packet +processing. This has proved super-useful when trying to troubleshooting +networking problems in production. + +A simple scenario +----------------- + +a) nfdhcpd starts. Upon initialization, it creates an NFQUEUE (e.g., 42, +configurable), and listens on it for incoming DHCP requests. It also begins to +watch its state directory, `/var/lib/nfdhcpd` via inotify(). + +b) A new VM gets created, let's assume its NIC has address mac0, lives on TAP +interface tap0, and is to receive IP address ip0 via DHCP. + +c) Someone (e.g., a Ganeti KVM ifup script, or in our case snf-network [2] +creates a new binding file informing nfdhcpd that it is to reply to DHCP +requests from MAC mac0 on TAP interface tap0, and include IP ip0 in the DHCP +reply. + +d) The ifup script or the administrator injects nfdhcpd in the processing +pipeline for packets coming from tap0, using iptables: + +.. code-block:: console + + # iptables -t mangle -A PREROUTING -i tap0 -m udp -p udp --dport 67 -j NFQUEUE --queue-num 42 + +e) From now on, whenever a DHCP request is sent out by the VM, the +iptables rule will forward the packet to nfdhcpd, which will consult +its bindings database, find the entry for tap0, verify the source MAC, +and inject a DHCP reply for the corresponding IP address into tap0. + +Binding file +------------ + +A binding file in nfdhcpd's state directory is named after the +physical interface where the daemon is to receive incoming DHCP requests +from, and defines at least the following variables: + +* ``INSTANCE``: The instance name related to this inteface + +* ``INDEV``: The logical interface where the packet is received on. For + bridged setups, the bridge interface, e.g., br0. Otherwise, same as + the file name. + +* ``MAC``: The MAC address where the DHCP request must be originating from + +* ``IP``: The IPv4 address to be returned in DHCP replies + +* ``SUBNET``: The IPv4 subnet to be returned in DHCP replies in CIDR form + +* ``GATEWAY``: The IPv4 gateway to be returned in DHCP replies + +* ``SUBNET6``: The IPv6 network prefix + +* ``GATEWAY6``: The IPv6 network gateway + +* ``EUI64``: The IPv6 address of the instance + + +nfdhcpd.conf +------------ + +The configuration file for nfdhcp is `/etc/nfdhpcd/nfdhcpd.conf`. Three +sections are defined: general, dhcp, ipv6. + +Note that nfdhcpd can run as nobody. This and other options related to +its execution environment are defined in general section. + +In the dhcp section we define the options related to DHCP responses. +Specifically: + +* ``enable_dhcp`` to globally enable/disable DHCP + +* ``server_ip`` a dummy IP that the VMs will as src IP of the response + +* ``dhcp_queue`` the a NFQUEUE number to listen on for DHCP requests + +| Please not that this queue *must* be used in iptables mangle rule. + +* ``nameservers`` IPv4 nameservers to include in DHCP responses + +* ``domain`` the domain to serve with the replies (optional) + +| If not given the instance's name (hostname) will be used instead. + +In the ipv6 section we define the options related to IPv6 responses. Currently +nfdhcpd supports IPv6 stateless configuration [3]. The instance will get an +auto-generated IPv6 (MAC to eui64) based on the IPv6 prefix exported by Router +Advertisements (O flag set, M flag unset). This kind of RA will make instance +query for nameservers and domain search list via DHCPv6 request. +nfdhcpd, currently and in case of IPv6, is supposed to work on a routed setup +where the instances are not on the same collision domain with the external +router and thus any RA/NA should be served locally. Specifically: + +* ``enable_ipv6`` to globally enable/disable IPv6 responses + +* ``ra_period`` to define how often nfdhcpd will send RAs to TAPs with IPv6 + +* ``rs_queue`` the NFQUEUE number to listen on for router solicitations + +* ``ns_queue`` the NFQUEUE number to listen on for neighbor solicitations + +* ``dhcp_queue`` the NFQUEUE number to listen on for DHCPv6 request + +* ``nmeservers`` the IPv6 nameservers + +| They can be send using the RDNSS option of the RA [4]. +| Since it is not supported by Windows we serve them via DHCPv6 responses + +* ``domains`` the domain search list + +| If not given the instance's name (hostname) will be used instead. + +iptables +-------- + +In order nfdhcpd to be able to process incoming requests you have to mangle +the corresponding packages. Please note that in case of bridged setup the +kernel understands that the packets are coming from the bridge (logical indev) +and not from the tap (physical indev). Specifically: + +* **DHCP**: ``iptables -t mangle -A PREROUTING -i tap+ -p udp --dport 67 -j NFQUEUE --queue-num 42`` + +* **RS**: ``ip6tables -t mangle -A PREROUTING -i tap+ -p icmpv6 --icmpv6-type router-solicitation -j NFQUEUE --queue-num 43`` + +* **NS**: ``ip6tables -t mangle -A PREROUTING -i tap+ -p icmpv6 --icmpv6-type neighbour-solicitation -j NFQUEUE --queue-num 44`` + +* **DHCPv6**: ``ip6tables -t mangle -A PREROUTING -i tap+ -p udp --dport 547 -j NFQUEUE --queue-num 45`` + +For a bridged setup replace tap+ with br+ in case of DHCP. Using nfdhcpd +for IPv6 in a bridged setup does not make any sense. The above rules are +included in `/etc/ferm/nfdhcpd.ferm` . +In case you use ferm, this file should be included in `/etc/ferm/ferm.conf`. +Otherwise an `rc.local` script can be used to issue those rules upon boot. + + + +| [1] https://www.wzdftpd.net/redmine/projects/nfqueue-bindings/wiki/ +| [2] https://code.grnet.gr/projects/snf-network/ +| [3] https://tools.ietf.org/html/rfc4862 +| [4] https://tools.ietf.org/html/rfc5006 diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..7e6dc5f --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,190 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +set I18NSPHINXOPTS=%SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\nfdhcpd.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\nfdhcpd.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end diff --git a/nfdhcpd b/nfdhcpd index 41980ce..c66c435 100755 --- a/nfdhcpd +++ b/nfdhcpd @@ -550,11 +550,13 @@ class VMNetProxy(object): # pylint: disable=R0902 if b.is_valid(): if self.mac_indexed_clients: self.clients[b.mac] = b + k = b.mac else: self.clients[ifindex] = b - logging.debug(" - Added client:") - logging.debug(" + %5s: %10s %20s %7s %15s", - ifindex, b.hostname, b.mac, b.tap, b.ip) + k = ifindex + logging.info(" - Added client:") + logging.info(" + %10s | %20s %20s %10s %20s %40s", + k, b.hostname, b.mac, b.tap, b.ip, b.eui64) def remove_tap(self, tap): """ Cleanup clients on a removed interface @@ -565,8 +567,8 @@ class VMNetProxy(object): # pylint: disable=R0902 if cl.tap == tap: logging.info("Removing client %s and closing socket on %s", cl.hostname, cl.tap) - logging.debug(" - %10s | %10s %20s %10s %20s", - k, cl.hostname, cl.mac, cl.tap, cl.ip) + logging.info(" - %10s | %20s %20s %10s %20s %40s", + k, cl.hostname, cl.mac, cl.tap, cl.ip, cl.eui64) cl.socket.close() del self.clients[k] except: @@ -740,6 +742,10 @@ class VMNetProxy(object): # pylint: disable=R0902 subnet = binding.net6 + if subnet.net is None: + logging.debug(" - No IPv6 network assigned for tap %s", binding.tap) + return + indevmac = self.get_iface_hw_addr(binding.indev) ifll = subnet.make_ll64(indevmac) if ifll is None: @@ -952,7 +958,7 @@ class VMNetProxy(object): # pylint: disable=R0902 if ifll is None: continue resp = Ether(src=indevmac)/\ - IPv6(src=str(ifll))/ICMPv6ND_RA(routerlifetime=14400)/\ + IPv6(src=str(ifll))/ICMPv6ND_RA(O=1, routerlifetime=14400)/\ ICMPv6NDOptPrefixInfo(prefix=str(subnet.prefix), prefixlen=subnet.prefixlen) if self.ipv6_nameservers: @@ -1040,11 +1046,11 @@ class VMNetProxy(object): # pylint: disable=R0902 timeout = self.ra_period - (time.time() - start) def print_clients(self): - logging.info("%10s %20s %20s %10s %20s", - 'Key', 'Client', 'MAC', 'TAP', 'IP') + logging.info("%10s %20s %20s %10s %20s %40s", + 'Key', 'Client', 'MAC', 'TAP', 'IP', 'IPv6') for k, cl in self.clients.items(): - logging.info("%10s | %20s %20s %10s %20s", - k, cl.hostname, cl.mac, cl.tap, cl.ip) + logging.info("%10s | %20s %20s %10s %20s %40s", + k, cl.hostname, cl.mac, cl.tap, cl.ip, cl.eui64)