lkml.org 
[lkml]   [2006]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH 03/03][IPROUTE2] EtherIP tunnel and device support for iproute2
    This patch adds support for EtherIP tunnels and devices to the iproute2
    userspace software package.

    Signed-off-by: Joerg Roedel <joro-lkml@zlug.org>
    diff -urp iproute2-2.6.16-060323.orig/ip/iptunnel.c iproute2-2.6.16-060323/ip/iptunnel.c
    --- iproute2-2.6.16-060323.orig/ip/iptunnel.c 2005-02-10 19:31:18.000000000 +0100
    +++ iproute2-2.6.16-060323/ip/iptunnel.c 2006-09-20 22:35:30.000000000 +0200
    @@ -44,7 +44,7 @@ static void usage(void) __attribute__((n
    static void usage(void)
    {
    fprintf(stderr, "Usage: ip tunnel { add | change | del | show } [ NAME ]\n");
    - fprintf(stderr, " [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n");
    + fprintf(stderr, " [ mode { ipip | gre | sit | etherip } ] [ remote ADDR ] [ local ADDR ]\n");
    fprintf(stderr, " [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n");
    fprintf(stderr, " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n");
    fprintf(stderr, "\n");
    @@ -202,6 +202,12 @@ static int parse_args(int argc, char **a
    exit(-1);
    }
    p->iph.protocol = IPPROTO_IPV6;
    + } else if (strcmp(*argv, "etherip") == 0) {
    + if (p->iph.protocol && p->iph.protocol != IPPROTO_ETHERIP) {
    + fprintf(stderr,"You managed to ask for more than one tunnel mode.\n");
    + exit(-1);
    + }
    + p->iph.protocol = IPPROTO_ETHERIP;
    } else {
    fprintf(stderr,"Cannot guess tunnel mode.\n");
    exit(-1);
    @@ -324,11 +330,15 @@ static int parse_args(int argc, char **a
    p->iph.protocol = IPPROTO_IPIP;
    else if (memcmp(p->name, "sit", 3) == 0)
    p->iph.protocol = IPPROTO_IPV6;
    + else if (memcmp(p->name, "ethip", 5) == 0)
    + p->iph.protocol = IPPROTO_ETHERIP;
    }

    - if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) {
    + if (p->iph.protocol == IPPROTO_IPIP ||
    + p->iph.protocol == IPPROTO_IPV6 ||
    + p->iph.protocol == IPPROTO_ETHERIP) {
    if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
    - fprintf(stderr, "Keys are not allowed with ipip and sit.\n");
    + fprintf(stderr, "Keys are not allowed with ipip, sit or etherip.\n");
    return -1;
    }
    }
    @@ -351,6 +361,21 @@ static int parse_args(int argc, char **a
    fprintf(stderr, "Broadcast tunnel requires a source address.\n");
    return -1;
    }
    +
    + if (p->iph.protocol == IPPROTO_ETHERIP) {
    + if ((cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) && !p->iph.daddr) {
    + fprintf(stderr, "EtherIP tunnel requires a "
    + "destination address.\n");
    + return -1;
    + }
    +
    + /*
    + if (cmd != SIOCDELTUNNEL && p->iph.frag_off & htons(IP_DF)) {
    + fprintf(stderr, "Warning: [no]pmtudisc is ignored on"
    + " EtherIP tunnels\n");
    + }
    + */
    + }
    return 0;
    }

    @@ -374,6 +399,8 @@ static int do_add(int cmd, int argc, cha
    return do_add_ioctl(cmd, "gre0", &p);
    case IPPROTO_IPV6:
    return do_add_ioctl(cmd, "sit0", &p);
    + case IPPROTO_ETHERIP:
    + return do_add_ioctl(cmd, "ethip0", &p);
    default:
    fprintf(stderr, "cannot determine tunnel mode (ipip, gre or sit)\n");
    return -1;
    @@ -395,6 +422,8 @@ int do_del(int argc, char **argv)
    return do_del_ioctl("gre0", &p);
    case IPPROTO_IPV6:
    return do_del_ioctl("sit0", &p);
    + case IPPROTO_ETHERIP:
    + return do_del_ioctl("ethip0", &p);
    default:
    return do_del_ioctl(p.name, &p);
    }
    @@ -418,7 +447,8 @@ void print_tunnel(struct ip_tunnel_parm
    p->name,
    p->iph.protocol == IPPROTO_IPIP ? "ip" :
    (p->iph.protocol == IPPROTO_GRE ? "gre" :
    - (p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown")),
    + (p->iph.protocol == IPPROTO_ETHERIP ? "etherip" :
    + (p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown"))),
    p->iph.daddr ? format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1)) : "any",
    p->iph.saddr ? rt_addr_n2a(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2)) : "any");

    @@ -431,19 +461,19 @@ void print_tunnel(struct ip_tunnel_parm
    if (p->iph.ttl)
    printf(" ttl %d ", p->iph.ttl);
    else
    - printf(" ttl inherit ");
    + printf(" ttl %s", p->iph.protocol != IPPROTO_ETHERIP ? "inherit " : "default");

    if (p->iph.tos) {
    SPRINT_BUF(b1);
    printf(" tos");
    if (p->iph.tos&1)
    - printf(" inherit");
    + printf(" %s", p->iph.protocol != IPPROTO_ETHERIP ? "inherit" : "default");
    if (p->iph.tos&~1)
    printf("%c%s ", p->iph.tos&1 ? '/' : ' ',
    rtnl_dsfield_n2a(p->iph.tos&~1, b1, sizeof(b1)));
    }

    - if (!(p->iph.frag_off&htons(IP_DF)))
    + if (p->iph.protocol != IPPROTO_ETHERIP && !(p->iph.frag_off&htons(IP_DF)))
    printf(" nopmtudisc");

    if ((p->i_flags&GRE_KEY) && (p->o_flags&GRE_KEY) && p->o_key == p->i_key)
    @@ -506,8 +536,13 @@ static int do_tunnels_list(struct ip_tun
    fprintf(stderr, "Failed to get type of [%s]\n", name);
    continue;
    }
    - if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT)
    +
    + if (type != ARPHRD_TUNNEL &&
    + type != ARPHRD_IPGRE &&
    + type != ARPHRD_SIT &&
    + type != ARPHRD_ETHERIP)
    continue;
    +
    memset(&p1, 0, sizeof(p1));
    if (do_get_ioctl(name, &p1))
    continue;
    diff -urp iproute2-2.6.16-060323.orig/lib/ll_types.c iproute2-2.6.16-060323/lib/ll_types.c
    --- iproute2-2.6.16-060323.orig/lib/ll_types.c 2005-02-09 23:07:24.000000000 +0100
    +++ iproute2-2.6.16-060323/lib/ll_types.c 2006-09-23 13:19:16.000000000 +0200
    @@ -118,6 +118,9 @@ __PF(IEEE802_TR,tr)
    #ifdef ARPHRD_IEEE80211
    __PF(IEEE80211,ieee802.11)
    #endif
    +#ifdef ARPHRD_ETHERIP
    +__PF(ETHERIP, etherip)
    +#endif
    #ifdef ARPHRD_VOID
    __PF(VOID,void)
    #endif
    \
     
     \ /
      Last update: 2006-09-23 14:23    [W:0.028 / U:33.336 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site