From f8ffbb09c5cb8094291b065f4059894e4c59ccd6 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 5 Jul 2013 13:48:22 +0100 Subject: [PATCH] Updated LinkHandler#change to retry commands with SETLINK when they fail with NEWLINK --- lib/linux/netlink/route/link_handler.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/linux/netlink/route/link_handler.rb b/lib/linux/netlink/route/link_handler.rb index aac7ed7..f0d6877 100644 --- a/lib/linux/netlink/route/link_handler.rb +++ b/lib/linux/netlink/route/link_handler.rb @@ -210,8 +210,16 @@ module Netlink iplink_modify(RTM_NEWLINK, NLM_F_CREATE|NLM_F_EXCL, opt) end + + # This will submit a change. If the kernel replies "protocol not + # supported" resend the request with a SETLINK instead of NEWLINK flag. + # def change(opt) - iplink_modify(RTM_NEWLINK, NLM_F_REPLACE, opt) + begin + iplink_modify(RTM_NEWLINK, NLM_F_REPLACE, opt) + rescue Errno::EOPNOTSUPP + iplink_modify(RTM_SETLINK, NLM_F_REPLACE, opt) + end end def replace(opt)