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

[radvd] Ensure at least one interface is specified in radvd.conf before starting radvd #1636

Merged
merged 2 commits into from
Apr 24, 2018
Merged
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions dockers/docker-router-advertiser/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@ fi
# Generate /etc/radvd.conf config file
sonic-cfggen -d -t /usr/share/sonic/templates/radvd.conf.j2 > /etc/radvd.conf

# Enusre at least one interface is specified in radvd.conf
NUM_IFACES=$(grep -c "^interface" /etc/radvd.conf)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of grep-ing a text file, you could first check by sonic-cfggen -d -v '...', if there are some interfaces:
then you could generate the conf file, and start job.

Copy link
Contributor Author

@jleveque jleveque Apr 24, 2018

Choose a reason for hiding this comment

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

Not only must there be VLANs, they must have IPv6 subnets. Checking all of the necessary conditions in a bash script with multiple calls to sonic-cfggen (and nested loops) is messy. Not to mention, I already wrote all of that logic into in radvd.conf.j2. Why duplicate the logic? If the template generates a conf file containing at least one interface, radvd should be started.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. One more comment: grep -c "^interface "
One more blank to make it more strict.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

if [ $NUM_IFACES -eq 0 ]; then
echo "No interfaces specified in radvd.conf. Not starting router advertiser process."
exit 0
fi

# Start the router advertiser
supervisorctl start radvd