]> Pileus Git - ~andy/linux/commitdiff
{pktgen, xfrm} Using "pgset spi xxx" to spedifiy SA for a given flow
authorFan Du <fan.du@windriver.com>
Fri, 3 Jan 2014 03:18:30 +0000 (11:18 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 3 Jan 2014 06:29:11 +0000 (07:29 +0100)
User could set specific SPI value to arm pktgen flow with IPsec
transformation, instead of looking up SA by sadr/daddr. The reaseon
to do so is because current state lookup scheme is both slow and, most
important of all, in fact pktgen doesn't need to match any SA state
addresses information, all it needs is the SA transfromation shell to
do the encapuslation.

And this option also provide user an alternative to using pktgen
test existing SA without creating new ones.

Signed-off-by: Fan Du <fan.du@windriver.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/core/pktgen.c

index 156d57b616ac6bcf4a8b6be718d1a35dc834ebd6..8bc4ddd375a9d8332bc1c3e023e63c625a1f0072 100644 (file)
@@ -389,6 +389,7 @@ struct pktgen_dev {
 #ifdef CONFIG_XFRM
        __u8    ipsmode;                /* IPSEC mode (config) */
        __u8    ipsproto;               /* IPSEC type (config) */
+       __u32   spi;
 #endif
        char result[512];
 };
@@ -1477,6 +1478,17 @@ static ssize_t pktgen_if_write(struct file *file,
                return count;
        }
 
+       if (!strcmp(name, "spi")) {
+               len = num_arg(&user_buffer[i], 10, &value);
+               if (len < 0)
+                       return len;
+
+               i += len;
+               pkt_dev->spi = value;
+               sprintf(pg_result, "OK: spi=%u", pkt_dev->spi);
+               return count;
+       }
+
        if (!strcmp(name, "flowlen")) {
                len = num_arg(&user_buffer[i], 10, &value);
                if (len < 0)