mirror_iproute2/man/man8/ip-vrf.8
David Ahern 1949f82cdf Introduce ip vrf command
'ip vrf' follows the user semnatics established by 'ip netns'.

The 'ip vrf' subcommand supports 3 usages:

1. Run a command against a given vrf:
       ip vrf exec NAME CMD

   Uses the recently committed cgroup/sock BPF option. vrf directory
   is added to cgroup2 mount. Individual vrfs are created under it. BPF
   filter attached to vrf/NAME cgroup2 to set sk_bound_dev_if to the VRF
   device index. From there the current process (ip's pid) is addded to
   the cgroups.proc file and the given command is exected. In doing so
   all AF_INET/AF_INET6 (ipv4/ipv6) sockets are automatically bound to
   the VRF domain.

   The association is inherited parent to child allowing the command to
   be a shell from which other commands are run relative to the VRF.

2. Show the VRF a process is bound to:
       ip vrf id
   This command essentially looks at /proc/pid/cgroup for a "::/vrf/"
   entry with the VRF name following.

3. Show process ids bound to a VRF
       ip vrf pids NAME
   This command dumps the file MNT/vrf/NAME/cgroup.procs since that file
   shows the process ids in the particular vrf cgroup.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2016-12-13 10:20:16 -08:00

89 lines
2.5 KiB
Groff

.TH IP\-VRF 8 "7 Dec 2016" "iproute2" "Linux"
.SH NAME
ip-vrf \- run a command against a vrf
.SH SYNOPSIS
.sp
.ad l
.in +8
.ti -8
.B ip
.B vrf
.RI " { " COMMAND " | "
.BR help " }"
.sp
.ti -8
.BR "ip vrf identify"
.RI "[ " PID " ]"
.ti -8
.BR "ip vrf pids"
.I NAME
.ti -8
.BR "ip vrf exec "
.RI "[ " NAME " ] " command ...
.SH DESCRIPTION
A VRF provides traffic isolation at layer 3 for routing, similar to how a
VLAN is used to isolate traffic at layer 2. Fundamentally, a VRF is a separate
routing table. Network devices are associated with a VRF by enslaving the
device to the VRF. At that point network addresses assigned to the device are
local to the VRF with host and connected routes moved to the table associated
with the VRF.
A process can specify a VRF using several APIs -- binding the socket to the
VRF device using SO_BINDTODEVICE, setting the VRF association using
IP_UNICAST_IF or IPV6_UNICAST_IF, or specifying the VRF for a specific message
using IP_PKTINFO or IPV6_PKTINFO.
By default a process is not bound to any VRF. An association can be set
explicitly by making the program use one of the APIs mentioned above or
implicitly using a helper to set SO_BINDTODEVICE for all IPv4 and IPv6
sockets (AF_INET and AF_INET6) when the socket is created. This ip-vrf command
is a helper to run a command against a specific VRF with the VRF association
inherited parent to child.
.TP
.B ip vrf exec [ NAME ] cmd ... - Run cmd against the named VRF
.sp
This command allows applications that are VRF unaware to be run against
a VRF other than the default VRF (main table). A command can be run against
the default VRF by passing the "default" as the VRF name. This is useful if
the current shell is associated with another VRF (e.g, Management VRF).
.TP
.B ip vrf identify [PID] - Report VRF association for process
.sp
This command shows the VRF association of the specified process. If PID is
not specified then the id of the current process is used.
.TP
.B ip vrf pids NAME - Report processes associated with the named VRF
.sp
This command shows all process ids that are associated with the given
VRF.
.SH CAVEATS
This command requires a kernel compiled with CGROUPS and CGROUP_BPF enabled.
The VRF helper *only* affects network layer sockets.
.SH EXAMPLES
.PP
ip vrf exec red ssh 10.100.1.254
.RS
Executes ssh to 10.100.1.254 against the VRF red table.
.RE
.SH SEE ALSO
.br
.BR ip (8),
.BR ip-link (8),
.BR ip-address (8),
.BR ip-route (8),
.BR ip-neighbor (8)
.SH AUTHOR
Original Manpage by David Ahern