Merge "Dynamically determine overlay network mtu"

This commit is contained in:
Zuul 2018-07-02 10:28:33 +00:00 committed by Gerrit Code Review
commit 90ed26769c
4 changed files with 43 additions and 5 deletions

View File

@ -34,9 +34,12 @@ inventory in order to work:
VXLAN Network Identifier offset (openvswitch key).
.. zuul:rolevar:: bridge_mtu
:default: 1450
:default: Smallest mtu less 50 bytes for vxlan overhead
Bridge interface MTU.
Bridge interface MTU. By default we determine this value by checking
all interfaces on host, taking the smallest MTU and subtracting by
50 for vxlan overhead. Can be overridden explicitly if this does not
work.
.. zuul:rolevar:: bridge_name
:default: br-infra

View File

@ -1,5 +1,4 @@
bridge_vni_offset: 1000000
bridge_mtu: 1450
bridge_name: br-infra
bridge_authorize_internal_traffic: false

View File

@ -52,3 +52,37 @@
when:
- bridge_configure_address | bool
- bridge_authorize_internal_traffic | bool
- when: bridge_mtu is not defined
block:
- name: Determine bridge mtu
shell: |
# Find all interfaces with a permanent mac address type.
# Permanent mac addrs imply "real" hardware and not interfaces we have
# created through this system. This makes our MTU determination mostly
# idempotent allowing us to create multiple overlays without
# perpetually smaller MTUs.
SMALLEST_MTU=""
for X in $(ls /sys/class/net) ; do
MAC_TYPE=$(cat "/sys/class/net/${X}/addr_assign_type")
if [ "$MAC_TYPE" -ne "0" ] ; then
# Type 0 is a permanent address implying a "real"
# interface. We ignore other interfaces as that is what we
# create here
continue
fi
MTU=$(cat "/sys/class/net/${X}/mtu")
if [ -z "$SMALLEST_MTU" ] || [ "$SMALLEST_MTU" -gt "$MTU" ] ; then
SMALLEST_MTU=$MTU
fi
done
# 50 byte overhead for vxlan
echo $(( SMALLEST_MTU - 50 ))
args:
executable: /bin/bash
environment:
PATH: '{{ ansible_env.PATH }}:/bin:/sbin:/usr/sbin'
register: mtu_output
- name: Set bridge_mtu
set_fact:
bridge_mtu: "{{ mtu_output.stdout }}"

View File

@ -1,8 +1,10 @@
- include: common.yaml
# Note (dmsimard)
# We explicitely declare a PATH environment variable because '/sbin' is not in
# PATH when using 'become: yes' on some distributions
- include: common.yaml
environment:
PATH: "{{ ansible_env.PATH }}:/sbin:/usr/sbin"
- include: switch.yaml
environment:
PATH: "{{ ansible_env.PATH }}:/sbin:/usr/sbin"