Updated LinkHandler#change to retry commands with SETLINK when they fail with NEWLINK

This commit is contained in:
Patrick J Cherry
2013-07-05 13:48:22 +01:00
parent 55c38a4877
commit f8ffbb09c5

View File

@@ -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)