Compare commits
7 Commits
0.13-1+squ
...
0.15
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6cbda4bb58 | ||
![]() |
e0aae9c67c | ||
![]() |
e96601981b | ||
![]() |
8bbb45af33 | ||
![]() |
d86d0c8408 | ||
![]() |
0281a5e4eb | ||
![]() |
84c0414550 |
@@ -25,7 +25,7 @@ module Netlink
|
||||
# Check the sockaddr on a received message. Raises an error if the AF
|
||||
# is not AF_NETLINK or the PID is not 0 (this is important for security)
|
||||
def self.check_sockaddr(str)
|
||||
af, pad, pid, groups = str.unpack(SOCKADDR_PACK)
|
||||
af, _, pid, _ = str.unpack(SOCKADDR_PACK)
|
||||
raise "Bad AF #{af}!" if af != Socket::AF_NETLINK
|
||||
raise "Bad PID #{pid}!" if pid != 0
|
||||
end
|
||||
@@ -135,8 +135,8 @@ module Netlink
|
||||
# (Compare: rtnl_talk in lib/libnetlink.c, with answer=NULL)
|
||||
def cmd(type, msg, flags=NLM_F_REQUEST, resp_type=NLMSG_ERROR, timeout=@timeout, sockaddr=SOCKADDR_DEFAULT)
|
||||
send_request(type, msg, flags|NLM_F_ACK, sockaddr)
|
||||
receive_responses(true, timeout) do |type,msg|
|
||||
return msg if type == resp_type
|
||||
receive_responses(true, timeout) do |rtype,rmsg|
|
||||
return rmsg if rtype == resp_type
|
||||
false
|
||||
end
|
||||
end
|
||||
@@ -144,7 +144,7 @@ module Netlink
|
||||
# Discard all waiting messages
|
||||
def drain
|
||||
while select([@socket], nil, nil, 0)
|
||||
mesg, sender, rflags, controls = @socket.recvmsg
|
||||
mesg, _, _, _ = @socket.recvmsg
|
||||
raise EOFError unless mesg
|
||||
end
|
||||
end
|
||||
@@ -209,7 +209,7 @@ module Netlink
|
||||
# kernel closes the socket.
|
||||
def recvmsg(timeout=@timeout)
|
||||
if select([@socket], nil, nil, timeout)
|
||||
mesg, sender, rflags, controls = @socket.recvmsg
|
||||
mesg, sender, _, _ = @socket.recvmsg
|
||||
raise EOFError unless mesg
|
||||
sender = sender.to_sockaddr if sender.respond_to? :to_sockaddr
|
||||
NLSocket.check_sockaddr(sender)
|
||||
|
@@ -122,6 +122,7 @@ module Netlink
|
||||
:unpack => lambda { |str,obj| VlanFlags.parse(str) }
|
||||
rtattr :egress_qos, IFLA_VLAN_EGRESS_QOS
|
||||
rtattr :ingress_qos, IFLA_VLAN_INGRESS_QOS
|
||||
rtattr :protocol, IFLA_VLAN_PROTOCOL, :ushort
|
||||
end
|
||||
|
||||
module Route
|
||||
|
@@ -8,12 +8,12 @@ module Netlink
|
||||
def clear_cache
|
||||
# No cache
|
||||
end
|
||||
|
||||
|
||||
def list(filter={}, &blk)
|
||||
@rtsocket.link.list(filter.merge(:kind=>"vlan"))
|
||||
end
|
||||
alias :each :list
|
||||
|
||||
|
||||
# Higher-level API to manipulate VLAN interface.
|
||||
# nl.vlans.add(
|
||||
# :link=>"lo",
|
||||
@@ -24,15 +24,15 @@ module Netlink
|
||||
def add(opt)
|
||||
@rtsocket.link.add(vlan_options(opt))
|
||||
end
|
||||
|
||||
|
||||
def change(opt)
|
||||
@rtsocket.link.change(vlan_options(opt))
|
||||
end
|
||||
|
||||
|
||||
def replace(opt)
|
||||
@rtsocket.link.replace(vlan_options(opt))
|
||||
end
|
||||
|
||||
|
||||
# Delete vlan given :link and :vlan_id. If you want to delete
|
||||
# by :index then call link.delete instead.
|
||||
def delete(opt)
|
||||
@@ -59,6 +59,7 @@ module Netlink
|
||||
end
|
||||
li.data.egress_qos = opt.delete(:egress_qos) if opt.has_key?(:egress_qos)
|
||||
li.data.ingress_qos = opt.delete(:ingress_qos) if opt.has_key?(:ingress_qos)
|
||||
li.data.protocol = opt.delete(:protocol) if opt.has_key?(:protocol)
|
||||
opt
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user