Add docker-router-advertiser to support IPv6 router advertisements (#1103)

This commit is contained in:
Joe LeVeque 2017-11-14 14:40:15 -08:00 committed by GitHub
parent 803c263331
commit cea87e985c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 134 additions and 0 deletions

1
.gitignore vendored
View File

@ -46,6 +46,7 @@ dockers/docker-fpm-quagga/Dockerfile
dockers/docker-lldp-sv2/Dockerfile
dockers/docker-orchagent/Dockerfile
dockers/docker-platform-monitor/Dockerfile
dockers/docker-router-advertiser/Dockerfile
dockers/docker-snmp-sv2/Dockerfile
dockers/docker-teamd/Dockerfile
dockers/docker-sonic-mgmt/Dockerfile

View File

@ -0,0 +1,32 @@
FROM docker-config-engine
# Make apt-get non-interactive
ENV DEBIAN_FRONTEND=noninteractive
# Update apt's cache of available packages
RUN apt-get update
# Install radvd Debian package
RUN apt-get -y install radvd
{% if docker_router_advertiser_debs.strip() -%}
# Copy built Debian packages
{%- for deb in docker_router_advertiser_debs.split(' ') %}
COPY debs/{{ deb }} debs/
{%- endfor %}
# Install built Debian packages and implicitly install their dependencies
{%- for deb in docker_router_advertiser_debs.split(' ') %}
RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt debs/{{ deb }}
{%- endfor %}
{%- endif %}
# Clean up
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs
COPY ["start.sh", "/usr/bin/"]
COPY ["docker-router-advertiser.supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["radvd.conf.j2", "/usr/share/sonic/templates/"]
ENTRYPOINT ["/usr/bin/supervisord"]

View File

@ -0,0 +1,28 @@
[supervisord]
logfile_maxbytes=1MB
logfile_backups=2
nodaemon=true
[program:start.sh]
command=/usr/bin/start.sh
priority=1
autostart=true
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:rsyslogd]
command=/usr/sbin/rsyslogd -n
priority=2
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
[program:radvd]
command=/usr/sbin/radvd -n
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog

View File

@ -0,0 +1,37 @@
{% block banner %}
# =========== Managed by sonic-cfggen -- DO NOT edit manually! ====================
# Generated by /usr/share/sonic/templates/radvd.conf.j2 using config DB data
# File: /etc/radvd.conf
#
{% endblock banner %}
# Config file for radvd, the router advertisement daemon
# See man page for radvd.conf for descriptions of all available options
#
{# If our configuration has VLAN interfaces... #}
{% if VLAN_INTERFACE %}
{% for (name, prefix) in VLAN_INTERFACE %}
{# If this VLAN has an IPv6 address... #}
{% if prefix | ipv6 %}
interface {{ name }}
{
IgnoreIfMissing on;
AdvSendAdvert on;
MinRtrAdvInterval 200;
MaxRtrAdvInterval 600;
AdvManagedFlag on;
AdvOtherConfigFlag off;
AdvLinkMTU 9100;
AdvHomeAgentFlag off;
prefix {{ prefix | network }}/{{ prefix | prefixlen }} {
AdvOnLink on;
AdvAutonomous off;
AdvRouterAddr off;
AdvValidLifetime infinity;
AdvPreferredLifetime infinity;
};
};
{% endif %}
{% endfor %}
{% endif %}

View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Generate /etc/radvd.conf config file
sonic-cfggen -d -t /usr/share/sonic/templates/radvd.conf.j2 > /etc/radvd.conf
rm -f /var/run/rsyslogd.pid
supervisorctl start rsyslogd
# Start the router advertiser
supervisorctl start radvd

View File

@ -0,0 +1,13 @@
[Unit]
Description=Router advertiser container
Requires=docker.service
After=swss.service
[Service]
User={{ sonicadmin_user }}
ExecStartPre=/usr/bin/{{ docker_container_name }}.sh start
ExecStart=/usr/bin/{{ docker_container_name }}.sh attach
ExecStop=/usr/bin/{{ docker_container_name }}.sh stop
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,12 @@
# Docker image for router advertiser
DOCKER_ROUTER_ADVERTISER = docker-router-advertiser.gz
$(DOCKER_ROUTER_ADVERTISER)_PATH = $(DOCKERS_PATH)/docker-router-advertiser
$(DOCKER_ROUTER_ADVERTISER)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE)
SONIC_DOCKER_IMAGES += $(DOCKER_ROUTER_ADVERTISER)
SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_ROUTER_ADVERTISER)
$(DOCKER_ROUTER_ADVERTISER)_CONTAINER_NAME = radv
$(DOCKER_ROUTER_ADVERTISER)_RUN_OPT += --net=host --privileged -t
$(DOCKER_ROUTER_ADVERTISER)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro