mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-18 23:50:12 +00:00

Both tunnels use legacy /proc/net/dev interface to get tunnel device and it's statistics. This may cause problems for cases when procfs either not mounted or not unshare(2)d for given network namespace. Use netlink to walk through list of tunnel devices which is network namespace aware and provides additional information such as statistics in the dump message. Since both address family specific variants of do_tunnels_list() nearly the same, except for tunnel parameters structure initialization, matching and printing we can introduce common one in tunnel.c. To implement address family specific parts introduce new data structure @struct tnl_print_nlmsg_info what contains all necessary information as well as pointers to ->init(), ->match() and ->print() callbacks. Annotate data structures by const where appropriate. Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com> Signed-off-by: David Ahern <dsahern@gmail.com>
60 lines
1.8 KiB
C
60 lines
1.8 KiB
C
/*
|
|
* Copyright (C)2006 USAGI/WIDE Project
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses>.
|
|
*/
|
|
/*
|
|
* Author:
|
|
* Masahide NAKAMURA @USAGI
|
|
*/
|
|
#ifndef __TUNNEL_H__
|
|
#define __TUNNEL_H__ 1
|
|
|
|
#include <stdbool.h>
|
|
#include <linux/types.h>
|
|
|
|
struct rtattr;
|
|
struct ifinfomsg;
|
|
|
|
extern struct rtnl_handle rth;
|
|
|
|
struct tnl_print_nlmsg_info {
|
|
const struct ifinfomsg *ifi;
|
|
const void *p1;
|
|
void *p2;
|
|
|
|
void (*init)(const struct tnl_print_nlmsg_info *info);
|
|
bool (*match)(const struct tnl_print_nlmsg_info *info);
|
|
void (*print)(const void *t);
|
|
};
|
|
|
|
int do_tunnels_list(struct tnl_print_nlmsg_info *info);
|
|
|
|
const char *tnl_strproto(__u8 proto);
|
|
|
|
int tnl_get_ioctl(const char *basedev, void *p);
|
|
int tnl_add_ioctl(int cmd, const char *basedev, const char *name, void *p);
|
|
int tnl_del_ioctl(const char *basedev, const char *name, void *p);
|
|
int tnl_prl_ioctl(int cmd, const char *name, void *p);
|
|
int tnl_6rd_ioctl(int cmd, const char *name, void *p);
|
|
int tnl_ioctl_get_6rd(const char *name, void *p);
|
|
__be32 tnl_parse_key(const char *name, const char *key);
|
|
void tnl_print_encap(struct rtattr *tb[],
|
|
int encap_type, int encap_flags,
|
|
int encap_sport, int encap_dport);
|
|
void tnl_print_endpoint(const char *name,
|
|
const struct rtattr *rta, int family);
|
|
|
|
#endif
|