Device indices are unsigned and use if_nametoindex as fallback
This commit is contained in:
parent
9bec1a4363
commit
99f830de2f
|
|
@ -1,3 +1,9 @@
|
||||||
|
2005-06-07 Stephen Hemminger <shemminger@osdl.org>
|
||||||
|
|
||||||
|
* Fix 'ip link' map to handle case where device gets autoloaded
|
||||||
|
by using if_nametoindex as fallback
|
||||||
|
* Device indices are unsigned not int.
|
||||||
|
|
||||||
2005-06-07 Masahide NAKAMURA <nakam@linux-ipv6.org>
|
2005-06-07 Masahide NAKAMURA <nakam@linux-ipv6.org>
|
||||||
|
|
||||||
* [ip] show timestamp when using '-t' option.
|
* [ip] show timestamp when using '-t' option.
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
extern int ll_remember_index(const struct sockaddr_nl *who,
|
extern int ll_remember_index(const struct sockaddr_nl *who,
|
||||||
struct nlmsghdr *n, void *arg);
|
struct nlmsghdr *n, void *arg);
|
||||||
extern int ll_init_map(struct rtnl_handle *rth);
|
extern int ll_init_map(struct rtnl_handle *rth);
|
||||||
extern int ll_name_to_index(const char *name);
|
extern unsigned ll_name_to_index(const char *name);
|
||||||
extern const char *ll_index_to_name(int idx);
|
extern const char *ll_index_to_name(unsigned idx);
|
||||||
extern const char *ll_idx_n2a(int idx, char *buf);
|
extern const char *ll_idx_n2a(unsigned idx, char *buf);
|
||||||
extern int ll_index_to_type(int idx);
|
extern int ll_index_to_type(unsigned idx);
|
||||||
extern unsigned ll_index_to_flags(int idx);
|
extern unsigned ll_index_to_flags(unsigned idx);
|
||||||
|
|
||||||
#endif /* __LL_MAP_H__ */
|
#endif /* __LL_MAP_H__ */
|
||||||
|
|
|
||||||
16
lib/ll_map.c
16
lib/ll_map.c
|
|
@ -17,6 +17,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#include <net/if.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libnetlink.h"
|
#include "libnetlink.h"
|
||||||
|
|
@ -25,7 +26,7 @@
|
||||||
struct idxmap
|
struct idxmap
|
||||||
{
|
{
|
||||||
struct idxmap * next;
|
struct idxmap * next;
|
||||||
int index;
|
unsigned index;
|
||||||
int type;
|
int type;
|
||||||
int alen;
|
int alen;
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
|
|
@ -86,7 +87,7 @@ int ll_remember_index(const struct sockaddr_nl *who,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ll_idx_n2a(int idx, char *buf)
|
const char *ll_idx_n2a(unsigned idx, char *buf)
|
||||||
{
|
{
|
||||||
struct idxmap *im;
|
struct idxmap *im;
|
||||||
|
|
||||||
|
|
@ -100,14 +101,14 @@ const char *ll_idx_n2a(int idx, char *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *ll_index_to_name(int idx)
|
const char *ll_index_to_name(unsigned idx)
|
||||||
{
|
{
|
||||||
static char nbuf[16];
|
static char nbuf[16];
|
||||||
|
|
||||||
return ll_idx_n2a(idx, nbuf);
|
return ll_idx_n2a(idx, nbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ll_index_to_type(int idx)
|
int ll_index_to_type(unsigned idx)
|
||||||
{
|
{
|
||||||
struct idxmap *im;
|
struct idxmap *im;
|
||||||
|
|
||||||
|
|
@ -119,7 +120,7 @@ int ll_index_to_type(int idx)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ll_index_to_flags(int idx)
|
unsigned ll_index_to_flags(unsigned idx)
|
||||||
{
|
{
|
||||||
struct idxmap *im;
|
struct idxmap *im;
|
||||||
|
|
||||||
|
|
@ -132,7 +133,7 @@ unsigned ll_index_to_flags(int idx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ll_name_to_index(const char *name)
|
unsigned ll_name_to_index(const char *name)
|
||||||
{
|
{
|
||||||
static char ncache[16];
|
static char ncache[16];
|
||||||
static int icache;
|
static int icache;
|
||||||
|
|
@ -152,7 +153,8 @@ int ll_name_to_index(const char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
|
return if_nametoindex(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ll_init_map(struct rtnl_handle *rth)
|
int ll_init_map(struct rtnl_handle *rth)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue