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

[fix] LOCAL_IFNAME and GUEST_IFNAME max name size #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Oct 30, 2016

  1. [fix] LOCAL_IFNAME and GUEST_IFNAME max name size

    A bug fix for the automatic creation logic of the LOCAL_IFNAME and GUEST_IFNAME vars values.
    
    1. Problem description
    Pipework always automatically computes the value of the $GUEST_IFNAME var. This var is used to define the name of the guest interface before it's added to the guest's NS and it's subsequently renamed to the value of the $CONTAINER_IFNAME. The actual value is computed as follow: 
    
        - GUEST_IFNAME=v${CONTAINER_IFNAME}pg${NSPID} if the IFTYPE is "bridge"
        - GUEST_IFNAME=ph$NSPID$CONTAINER_IFNAME if the $IFTYPE is "phys"
        - GUEST_IFNAME=du$NSPID$CONTAINER_IFNAME if the $IFTYPE is "dummy"
    
    However, specifying a long but valid $CONTAINER_IFNAME (up to i.e. IF_NAMSIZ chars in linux) does rise and error, because the concatenated string for the $GUEST_IFNAME var will be then larger than the maximum allowed value (again IF_NAMSIZ in the linux case).
    
    The same issue arises in this scenario if a -i option isn't passed to pipework to specify a valid $LOCAL_IFNAME, as the value for this var is computed in the exact same way described above (using "pg" instead of "pl" in the concatenated string)
    
    
    2. Example
    # pipework br_pub_5 -i pub_lan_7 base 192.168.4.27/24
    Error: argument "vpub_lan_7pl28223" is wrong: "name" too long
    
    
    3. Fix
    To fix this issue, the algorith to compute the value of $GUEST_IFNAME and $LOCAL_IFNAME has been modified in this way:
    
        - a $IF_NAME_MAX_SIZE constant is added to the script to define the max size for a valid network interface name. I'm unaware of a multi-platform, reliable way to autodetect this value, so I've used a constant to store it
        - the name of the interface is computed as: veth${NSPID}_${RANDOM_STRING} for the $LOCAL_IFNAME var (if -i isn't specified)
        - the name of the interface is computed as: teth${NSPID}_${RANDOM_STRING} for the $GUEST_IFNAME var
        - in both cases, the lenght of $LOCAL_IFNAME and $GUEST_IFNAME will be guaranteed lower than the $IF_NAME_MAX_SIZE
    
    4. ToDo
    The $GUEST_IFNAME var is automatically computed also if the $IFTYPE var is "ipoib". The same issue could potentially arise if $IFNAME is as long as IF_NAMSIZ, as the $GUEST_IFNAME is computed longer than $IFTYPE. However I'm unsure about the interface naming requirements for this networking layer and cannot test it. So this case should be checked and the automatic value should be computed accordingly
    ass3mbler authored Oct 30, 2016
    Configuration menu
    Copy the full SHA
    f7922f6 View commit details
    Browse the repository at this point in the history