netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC net-next 0/4] Support UID range routing.
@ 2014-04-26  4:48 Lorenzo Colitti
  2014-04-26  4:48 ` [RFC net-next 1/4] net: ipv6: Introduce flowi6_init_output Lorenzo Colitti
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Lorenzo Colitti @ 2014-04-26  4:48 UTC (permalink / raw)
  To: netdev; +Cc: hannes, davem, jpa, Lorenzo Colitti

In some environments it is useful to route packets differently
based on the user ID. This can be done with iptables owner match
and MASQUERADE, but that forces the use of iptables to fix up
parameters such as MSS and imposes a per-packet cost, plus it
breaks applications that expect end-to-end.

This patch series adds support for routing on the UID that owns
the socket and allow userspace to configure routing rules based
on UID ranges.

Points I'd like feedback on:

1. The code uses sock_i_uid, which grabs sk_callback_lock.
   Is that necessary? For example, xt_owner doesn't grab it - it
   just dereferences sk->sk_socket->file. If it is necessary, I
   don't know know how much contention it can cause. Should UID
   routing be made a config option as a result?
2. This patch defines new fib attributes (FRA_UID_START and
   FRA_UID_END) at the end of the currently-defined range.
   Should it instead replace some FRA_UNUSED_x attributes?
3. Is is a bad idea to use two attributes? I played around with
   making this an array of two integers, or a struct, but the
   results seemed uglier than the current code.

Limitations:

1. Sockets that have been closed have no UID any more. I think
   xt_owner also has this limitation - it's because the UID
   is in the struct socket, which is gone at that point. This
   could be fixed by writing the UID back into the struct sock
   sock when orphaning the socket.
2. Path MTU discovery does not (yet) specify the UID in the
   routing lookup to clone the route. This is not hard to fix
   but I haven't gotten around to it yet. A packet too big or DF
   needed packet will still affect the MTU of the socket that
   caused it though.

Tested:

Black-box tested using user-mode Linux by pointing different
UIDs to different TAP interfaces. Tested the following in IPv4
and IPv6:

- TCP inbound and outbound connections
- UDP send connect+send
- Ping
- Userspace communication using a patched IP binary:
  - UID range rule add / delete
  - Route lookup with a UID

Lorenzo Colitti (4):
  net: ipv6: Introduce flowi6_init_output.
  net: core: Add a UID range to fib rules.
  net: core: Add the UID to flowi[46]_init_output.
  net: core: Add a RTA_UID attribute to routes.

 include/net/fib_rules.h          |  6 ++++-
 include/net/flow.h               | 31 ++++++++++++++++++++++-
 include/net/ip.h                 |  1 +
 include/net/route.h              |  5 ++--
 include/uapi/linux/fib_rules.h   |  2 ++
 include/uapi/linux/rtnetlink.h   |  1 +
 net/core/fib_rules.c             | 53 ++++++++++++++++++++++++++++++++++++++--
 net/ipv4/fib_frontend.c          |  1 +
 net/ipv4/inet_connection_sock.c  |  6 +++--
 net/ipv4/ip_output.c             |  3 ++-
 net/ipv4/ping.c                  |  3 ++-
 net/ipv4/raw.c                   |  3 ++-
 net/ipv4/route.c                 | 19 +++++++++-----
 net/ipv4/syncookies.c            |  3 ++-
 net/ipv4/udp.c                   |  3 ++-
 net/ipv6/af_inet6.c              | 13 ++++------
 net/ipv6/datagram.c              | 12 ++++-----
 net/ipv6/inet6_connection_sock.c | 25 ++++++++-----------
 net/ipv6/raw.c                   |  1 +
 net/ipv6/route.c                 |  7 ++++++
 net/ipv6/syncookies.c            | 13 +++++-----
 net/ipv6/tcp_ipv6.c              | 12 ++++-----
 net/ipv6/udp.c                   |  1 +
 23 files changed, 161 insertions(+), 63 deletions(-)

-- 
1.9.1.423.g4596e3a

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-05-12 20:25 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-26  4:48 [RFC net-next 0/4] Support UID range routing Lorenzo Colitti
2014-04-26  4:48 ` [RFC net-next 1/4] net: ipv6: Introduce flowi6_init_output Lorenzo Colitti
2014-04-26  5:56   ` Julian Anastasov
2014-04-27  4:03     ` Lorenzo Colitti
2014-04-28  7:07       ` Julian Anastasov
2014-04-26  4:48 ` [RFC net-next 2/4] net: core: Add a UID range to fib rules Lorenzo Colitti
2014-04-26  4:48 ` [RFC net-next 3/4] net: core: Add the UID to flowi[46]_init_output Lorenzo Colitti
2014-04-26  4:48 ` [RFC net-next 4/4] net: core: Add a RTA_UID attribute to routes Lorenzo Colitti
2014-04-26 13:14 ` [RFC net-next 0/4] Support UID range routing David Newall
2014-04-28 14:38   ` Lorenzo Colitti
     [not found]     ` <20140428.125807.409036177577836732.davem@davemloft.net>
2014-04-28 19:01       ` Lorenzo Colitti
2014-05-02 19:15         ` Lorenzo Colitti
2014-05-02 19:24           ` David Miller
2014-05-07  3:59             ` Lorenzo Colitti
2014-05-07  9:24               ` Hannes Frederic Sowa
2014-05-07 10:58                 ` Lorenzo Colitti
2014-05-11 21:45                   ` Hannes Frederic Sowa
2014-05-12 20:25                     ` Lorenzo Colitti
2014-04-30  4:36     ` Lorenzo Colitti
2014-04-30  7:52       ` David Newall
2014-04-30  8:04         ` Lorenzo Colitti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).