Commit Graph

30 Commits

Author SHA1 Message Date
Benedict Wong
a6af9f2e61 xfrm: add option to hide keys in state output
ip xfrm state show currently dumps keys unconditionally. This limits its
use in logging, as security information can be leaked.

This patch adds a nokeys option to ip xfrm ( state show | monitor ), which
prevents the printing of keys. This allows ip xfrm state show to be used
in logging without exposing keys.

Signed-off-by: Benedict Wong <benedictwong@google.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
2019-01-21 08:31:20 -08:00
Stephen Hemminger
fa92d8cb09 ipxfrm: make local functions static
Make functions only used in ipxfrm.c static.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-19 11:42:44 -08:00
David Ahern
cd554f2c2f Tree wide: Drop sockaddr_nl arg
No function, filter, or print function uses the sockaddr_nl arg,
so just drop it.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
2018-10-22 09:43:48 -07:00
Leon Romanovsky
aba736dc25 ip: Fix compilation break on old systems
As was reported [1], the iproute2 fails to compile on old systems,
in Cong's case, it was Fedora 19, in our case it was RedHat 7.2, which
failed with the following errors during compilation:

ipxfrm.c: In function ‘xfrm_selector_print’:
ipxfrm.c:479:7: error: ‘IPPROTO_MH’ undeclared (first use in this
function)
  case IPPROTO_MH:
       ^
ipxfrm.c:479:7: note: each undeclared identifier is reported only once
for each function it appears in
ipxfrm.c: In function ‘xfrm_selector_upspec_parse’:
ipxfrm.c:1345:8: error: ‘IPPROTO_MH’ undeclared (first use in this
function)
   case IPPROTO_MH:
        ^                                                                                                                                                            make[1]: *** [ipxfrm.o] Error 1

The reason to it is the order of headers files. The IPPROTO_MH field is
set in kernel's UAPI header file (in6.h), but only in case
__UAPI_DEF_IPPROTO_V6 is set before. That define comes from other kernel's
header file (libc-compat.h) and is set in case there are no previous
libc relevant declarations.

In ip code, the include of <netdb.h> causes to indirect inclusion of
<netinet/in.h> and it sets __UAPI_DEF_IPPROTO_V6 to be zero and prevents from
IPPROTO_MH declaration.

This patch takes the simplest possible approach to fix the compilation
error by checking if IPPROTO_MH was defined before and in case it
wasn't, it defines it to be the same as in the kernel.

[1] https://www.spinics.net/lists/netdev/msg463980.html

Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Riad Abo Raed <riada@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
2017-11-13 10:07:25 -08:00
Thomas Egerer
20e4840a0a xfrm_policy: Add filter option for socket policies
Listing policies on systems with a lot of socket policies can be
confusing due to the number of returned polices. Even if socket polices
are not of interest, they cannot be filtered. This patch adds an option
to filter all socket policies from the output.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2017-11-07 11:12:30 +09:00
Stephen Hemminger
a9ae195a21 xfrm: get #define's from linux includes
Use linux/ipsec.h and linux/in.h to get the definition of IP related
protocols.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2017-06-14 10:25:39 -07:00
Stephen Hemminger
4d98ab00de Fix FSF address in file headers 2013-12-06 15:05:07 -08:00
Joy Latten
2c319e1ab7 xfrm security context support
In the Linux kernel, ipsec policy and SAs can include a
security context to support MAC networking. This feature
is often referred to as "labeled ipsec".

This patchset adds security context support into ip xfrm
such that a security context can be included when
add/delete/display SAs and policies with the ip command.
The user provides the security context when adding
SAs and policies. If a policy or SA contains a security
context, the changes allow the security context to be displayed.

For example,
ip xfrm state
src 10.1.1.6 dst 10.1.1.2
	proto esp spi 0x00000301 reqid 0 mode transport
	replay-window 0
	auth hmac(digest_null) 0x3078
	enc cbc(des3_ede) 0x6970763672656164796c6f676f33646573636263696e3031
	security context root:system_r:unconfined_t:s0

Please  let me know if all is ok with the patchset.
Thanks!!

regards,
Joy

Signed-off-by:  Joy Latten <latten@austin.ibm.com>
2011-03-17 09:58:23 -07:00
Jamal Hadi Salim
f6fd52e626 xfrm: Introduce xfrm by mark
This patch carries basic infrastructure.
You need to make sure that the proper include/linux/xfrm.h is included
for it to compile.

Example:
2010-03-03 16:37:28 -08:00
Stephen Hemminger
c1cdf2d214 Fix typo in IPPROTO_DCCP 2009-08-06 14:38:18 -07:00
Masahide NAKAMURA
efe69c1b72 ip: xfrm: Fix flush message.
Fix xfrm state or policy flush message.
And minor updates are included:
o Use static buffer to show unknown value as string.
o Show policy type (ptype) only when kernel specified it.
o Clean-up xfrm_monitor.

Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-09-05 12:56:51 +01:00
Masahide NAKAMURA
c1fa225324 ip: xfrm: Fix policy and state flags.
o Support policy flag with string format.
  Note that kernel defines only one name "localok" for the flag
  and it has not had any effect currently.
o Support state flag value XFRM_STATE_NOPMTUDISC.
o Fix to show detailed flags value when "-s" option is used.
o Fix minor typo.

Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-09-05 12:56:32 +01:00
jamal
0bb4a4c20c see SAD info
Stephen,
Use this patch instead of the one i sent yesterday.
As before, you will need to pull include/linux/xfrm.h from
net-2.6 once Dave applies the kernel patch.

cheers,
jamal

[XFRM] see SAD info

i.e instead of something like ip xfrm state ls | grep -i src | wc -l
do:

ip xfrm state count
And you get the count; you can also pass -s to the command line and
get the hash info.

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
2007-06-19 16:16:06 -07:00
Stephen Hemminger
ae665a522b Remove trailing whitespace
Go through source files and remove all trailing whitespace

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:10:22 -08:00
Masahide NAKAMURA
0bf0fbc47e XFRM: Mobility header support.
Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:03:41 -08:00
Masahide NAKAMURA
c54f31eeb3 XFRM: support report message by monitor.
Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:03:34 -08:00
Masahide NAKAMURA
7ea4f5d33d XFRM: Mobile IPv6 route optimization support.
To support Mobile IPv6 RO, the following extension is included:
o Use XFRM_MODE_XXX macro instead of magic number
o New attribute option for all state: source address for
  deleting or getting message
o New attribute options for RO: care-of address, last-used timestamp
  and wild-receive flag

Note:
Flush command like `ip xfrm state flush` is to remove all XFRM state.
It has been effected for IPsec SAD but with this patch it flushes both
IPsec SAD and Mobile IPv6 RO states.
To make only IPsec SA flush, it is recommanded to specify each XFRM
protocol like below:
 `ip x s f proto esp ; ip x s f proto ah ; ip x s f proto comp`

Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:03:32 -08:00
Masahide NAKAMURA
972938e9e6 XFRM: sub policy support.
Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
2006-12-05 10:03:23 -08:00
shemminger
27356a5e00 ndle DCCP in ipxfrm.c to allow using port numbers in the selector. 2006-01-12 18:31:36 +00:00
shemminger
669ae748d6 Minor fixes from Masahide for XFRM dynamic keying 2005-11-07 18:39:30 +00:00
linux-ipv6.org!nakam
48f1ef9f15 split printing state/policy info function for xfrm common use.
(Logical change 1.175)
2005-03-22 16:13:21 +00:00
osdl.net!shemminger
5cf576d928 Add Esp-in-udp encapsulation
(Logical change 1.152)
2005-03-10 19:04:00 +00:00
7!tgraf
43d9d2de04 Remove obsolete XFRM_MAX_DEPTH and fix xfrm_xfrma_print prototype
(Logical change 1.129)
2005-01-18 22:11:58 +00:00
net[shemminger]!shemminger
eaa34ee35d Import patch iproute2.117
(Logical change 1.119)
2005-01-17 23:29:39 +00:00
osdl.net!shemminger
63d91b4fda Fix for older /usr/include headers.
(Logical change 1.105)
2004-10-20 23:22:30 +00:00
org[shemminger]!nakam
29aa4dd76c [iproute2] XFRM: fixing protocol
(Logical change 1.84)
2004-09-28 18:40:49 +00:00
net[shemminger]!shemminger
7809c61688 Import patch xrfm-msg.patch
(Logical change 1.64)
2004-08-11 23:41:38 +00:00
net[shemminger]!shemminger
30ff5089c4 Import patch iproute-xfrm.3
(Logical change 1.58)
2004-07-30 20:26:15 +00:00
net[shemminger]!shemminger
c7699875be Import patch ipxfrm-20040707_2.diff
(Logical change 1.53)
2004-07-07 17:05:56 +00:00
net[shemminger]!shemminger
7798b5237e Initial revision 2004-07-07 17:05:56 +00:00