[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1333960981.414.24.camel@cr0>
Date: Mon, 09 Apr 2012 16:43:01 +0800
From: Cong Wang <amwang@...hat.com>
To: Helge Deller <deller@....de>
Cc: Octavian Purdila <octavian.purdila@...el.com>,
netdev@...r.kernel.org, David Miller <davem@...emloft.net>,
Andrew Morton <akpm@...ux-foundation.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Frank Danapfel <fdanapfe@...hat.com>,
Laszlo Ersek <lersek@...hat.com>, shemminger@...tta.com
Subject: Re: [RFC] API to modify /proc/sys/net/ipv4/ip_local_reserved_ports
On Wed, 2012-04-04 at 22:24 +0200, Helge Deller wrote:
> I would like to follow up on my last patch series to be able to modify
> the contents of the /proc/sys/net/ipv4/ip_local_reserved_ports port list
> from userspace.
>
> My last patch (https://lkml.org/lkml/2012/3/10/187) was based on
> modifications to the proc interface, which - based on the feedback here
> on the list - seemed to not be the right way to go (although I personally
> still like the idea very much :-)).
>
> Anyway, with this RFC I would like to get feedback about a new proposed
> API and attached kernel patch.
>
> The idea is to introduce a new <optname> value for get/setsockopt()
> named SO_RESERVED_PORTS to get/set the ip_local_reserved_ports
> bitmap via standard get/setsockopt() syscalls.
> As far as I understand this seems to be similiar to how iptables works.
>
> An untested kernel patch for review and feedback is attached below.
>
> In userspace it then would be possible to write a new tool or to extend
> for example the "ip" tool to accept commands like:
> $> ip reserved_ports add 100-2000
> $> ip reserved_ports remove 50-60
> $> ip reserved_ports list (to show current reserved port list)
>
> This userspace tool could then read the port bitmap from kernel via
> a) socket(PF_INET, SOCK_RAW, IPPROTO_RAW)
> b) getsockopt(3, SOL_SOCKET, SO_RESERVED_PORTS, <bitmaplist>)
> and write back the results after modification via
> c) setsockopt(3, SOL_SOCKET, SO_RESERVED_PORTS, <bitmaplist>)
>
> Would that be an acceptable solution?
Hmm, it is indeed that bitmap fits for syscall rather than /proc file.
But it seems that using getsockopt()/setsockopt() makes it like it is a
per-socket setting, actually it is a system-wide setting. So I am
wondering if exporting a binary /proc file for this is a better
solution.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists