From 57bdc4ff4895dd91cc723d22eecadcf48945e87c Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Fri, 25 Apr 2014 22:51:22 +0530 Subject: introduce gre tunnel support This patch introduces gre tunnel support Signed-off-by: Susant Sahani Acked-by: Thomas Graf [thaller@redhat.com: change WS to TAB, fix code doc] Signed-off-by: Thomas Haller --- doc/route.txt | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'doc') diff --git a/doc/route.txt b/doc/route.txt index e5f06f75..746201a3 100644 --- a/doc/route.txt +++ b/doc/route.txt @@ -924,6 +924,85 @@ if((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) rtnl_link_put(link); ----- +[[link_ipgre]] +==== IPGRE + +[source,c] +----- +extern struct rtnl_link *rtnl_link_ipgre_alloc(void); +extern int rtnl_link_ipgre_add(struct nl_sock *sk, const char *name); + +extern int rtnl_link_ipgre_set_link(struct rtnl_link *link, uint32_t index); +extern uint32_t rtnl_link_ipgre_get_link(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_iflags(struct rtnl_link *link, uint16_t iflags); +extern uint16_t rtnl_link_get_iflags(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_oflags(struct rtnl_link *link, uint16_t oflags); +extern uint16_t rtnl_link_get_oflags(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_ikey(struct rtnl_link *link, uint32_t ikey); +extern uint32_t rtnl_link_get_ikey(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_okey(struct rtnl_link *link, uint32_t okey); +extern uint32_t rtnl_link_get_okey(struct rtnl_link *link) + +extern int rtnl_link_ipgre_set_local(struct rtnl_link *link, uint32_t addr); +extern uint32_t rtnl_link_ipgre_get_local(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_remote(struct rtnl_link *link, uint32_t addr); +extern uint32_t rtnl_link_ipgre_get_remote(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_ttl(struct rtnl_link *link, uint8_t ttl); +extern uint8_t rtnl_link_ipgre_get_ttl(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_tos(struct rtnl_link *link, uint8_t tos); +extern uint8_t rtnl_link_ipgre_get_tos(struct rtnl_link *link); + +extern int rtnl_link_ipgre_set_pmtudisc(struct rtnl_link *link, uint8_t pmtudisc); +extern uint8_t rtnl_link_ipgre_get_pmtudisc(struct rtnl_link *link); + +----- + +.Example: Add a ipgre tunnel device +[source,c] +----- +struct rtnl_link *link +struct in_addr addr + +/* allocate new link object of type vxlan */ +if(!(link = rtnl_link_ipgre_alloc())) + /* error */ + +/* set ipgre tunnel name */ +if ((err = rtnl_link_set_name(link, "ipgre-tun")) < 0) + /* error */ + +/* set link index */ +if ((err = rtnl_link_ipgre_set_link(link, if_index)) < 0) + /* error */ + +/* set local address */ +inet_pton(AF_INET, "192.168.254.12", &addr.s_addr); +if ((err = rtnl_link_ipgre_set_local(link, addr.s_addr)) < 0) + /* error */ + +/* set remote address */ +inet_pton(AF_INET, "192.168.254.13", &addr.s_addr +if ((err = rtnl_link_ipgre_set_remote(link, addr.s_addr)) < 0) + /* error */ + +/* set tunnel ttl */ +if ((err = rtnl_link_ipgre_set_ttl(link, 64)) < 0) + /* error */ + +if((err = rtnl_link_add(sk, link, NLM_F_CREATE)) < 0) + /* error */ + +rtnl_link_put(link); +----- + + == Neighbouring == Routing -- cgit v1.2.3