Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions dockers/docker-router-advertiser/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions dockers/docker-router-advertiser/radvd.conf.j2
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply similiar rule as this commit?

a69b353

Copy link
Contributor Author

@jleveque jleveque Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the referenced commit, the MTU is specified in the ConfigDB on a port-by-port basis, and is looked up in the PORT table by port name. However, we do not currently store the MTU length for VLAN interfaces in the ConfigDB. If we decide to store this value at a later point in time, we can modify this accordingly.

AdvHomeAgentFlag off;
prefix {{ prefix | network }}/{{ prefix | prefixlen }} {
AdvOnLink on;
AdvAutonomous off;
AdvRouterAddr off;
AdvValidLifetime infinity;
AdvPreferredLifetime infinity;
};
};

{% endif %}
{% endfor %}
{% endif %}
11 changes: 11 additions & 0 deletions dockers/docker-router-advertiser/start.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions files/build_templates/router_advertiser.service.j2
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions rules/docker-router-advertiser.mk
Original file line number Diff line number Diff line change
@@ -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