A linux interface is limited to IFNAMSIZ length (16). In case a tap interface is created, add a validity check for it.
Signed-off-by: Eli Britstein <[email protected]> --- lib/netdev-linux.c | 7 +++++++ tests/ovs-ofctl.at | 21 +-------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index f4d2685a2..32222b683 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -962,6 +962,13 @@ netdev_linux_common_construct(struct netdev *netdev_) name); return EINVAL; } + if (strlen(name) >= IFNAMSIZ) { + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 1); + + VLOG_WARN_RL(&rll, "%s: Linux forbids network device with this name " + "(too long)", name); + return ENAMETOOLONG; + } /* The device could be in the same network namespace or in another one. */ netnsid_unset(&netdev->netnsid); diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at index 751a934e4..871bdcc19 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -3105,33 +3105,14 @@ AT_KEYWORDS([port names]) OVS_VSWITCHD_START([\ -- add-port br0 xyzzy -- set Interface xyzzy type=dummy -- \ -- add-port br0 x-y -- set Interface x-y type=dummy -- \ - -- add-port br0 abc123 -- set Interface abc123 type=dummy -- \ - -- add-port br0 reallyverylongportname -- set Interface reallyverylongportname type=dummy -- \ - -- add-port br0 conflictinglongportname1 -- set Interface conflictinglongportname1 type=dummy -- \ - -- add-port br0 conflictinglongportname2 -- set Interface conflictinglongportname2 type=dummy]) + -- add-port br0 abc123 -- set Interface abc123 type=dummy]) # These plain port names should be accepted. AT_CHECK([ovs-ofctl add-flow br0 in_port=xyzzy,actions=x-y,abc123]) -# reallyverylongportname is accepted truncated, but not in full. -AT_CHECK([ovs-ofctl add-flow br0 in_port=reallyverylongp,actions=drop]) -AT_CHECK([ovs-ofctl add-flow br0 in_port=reallyverylongportname,actions=drop], - [1], [], [ovs-ofctl: reallyverylongportname: invalid or unknown port for in_port -]) - -# conflictinglongportname1 and 2 can't be accepted even truncated, since -# they conflict when truncated. -AT_CHECK([ovs-ofctl add-flow br0 in_port=conflictinglongportname1,actions=drop], [1], [], [ovs-ofctl: conflictinglongportname1: invalid or unknown port for in_port -]) -AT_CHECK([ovs-ofctl add-flow br0 in_port=conflictinglongportname2,actions=drop], [1], [], [ovs-ofctl: conflictinglongportname2: invalid or unknown port for in_port -]) -AT_CHECK([ovs-ofctl add-flow br0 in_port=conflictinglong,actions=drop], [1], [], [ovs-ofctl: conflictinglong: invalid or unknown port for in_port -]) - # Show that the port names get displayed properly and that port names that # aren't alphanumeric get quoted. AT_CHECK([ovs-ofctl --names dump-flows br0 | ofctl_strip | sort], [0], [dnl - in_port=reallyverylongp actions=drop in_port=xyzzy actions=output:"x-y",output:abc123 ]) OVS_VSWITCHD_STOP -- 2.34.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
