git: if_clone: Refactor if_clone_create()

Aaron LI aly at crater.dragonflybsd.org
Sat Aug 4 20:59:15 PDT 2018


commit 84cb91c376f39e5cbfcc52664bc818ac8154e0c6
Author: Aaron LI <aly at aaronly.me>
Date:   Fri Jun 22 21:47:22 2018 +0800

    if_clone: Refactor if_clone_create()
    
    In the wildcard case (the caller passes the interface name without
    a unit number), if_clone_create() should update the passed name
    parameter with the allocated unit number in order to make the caller
    know the name of the cloned interface, e.g., ifconfig(8) compares
    the passed and returned interface name.  Therefore the caller should
    preserve enough space (given by the "len" parameter) to hold the full
    interface name.  This shouldn't be a problem since the caller generally
    use the "struct if_clonereq" which has enough space for the name.
    
    For the name update code, use simple and clear strlcpy() to replace the
    hack with a for loop and obscure snprintf(), and return ENOSPC instead
    of panic.
    
    Simplify the ifnet lock a bit.

Summary of changes:
 sys/net/if_clone.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/84cb91c376f39e5cbfcc52664bc818ac8154e0c6


-- 
DragonFly BSD source repository



More information about the Commits mailing list