Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/libiproute/ll_map.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/networking/libiproute/ll_map.c
r2725 r3621 87 87 } 88 88 89 const char FAST_FUNC *ll_idx_n2a(int idx, char *buf) 89 static 90 const char FAST_FUNC *ll_idx_n2a(int idx/*, char *buf*/) 90 91 { 91 92 struct idxmap *im; … … 96 97 if (im) 97 98 return im->name; 98 snprintf(buf, 16, "if%d", idx); 99 return buf; 99 //snprintf(buf, 16, "if%d", idx); 100 //return buf; 101 return auto_string(xasprintf("if%d", idx)); 100 102 } 101 102 103 103 104 const char FAST_FUNC *ll_index_to_name(int idx) 104 105 { 105 static char nbuf[16]; 106 107 return ll_idx_n2a(idx, nbuf); 106 //static char nbuf[16]; 107 return ll_idx_n2a(idx/*, nbuf*/); 108 108 } 109 109 … … 137 137 { 138 138 int ret = 0; 139 int sock_fd;140 139 141 140 /* caching is not warranted - no users which repeatedly call it */ … … 165 164 } 166 165 } 167 /* We have not found the interface in our cache, but the kernel168 * may still know about it. One reason is that we may be using169 * module on-demand loading, which means that the kernel will170 * load the module and make the interface exist only when171 * we explicitely request it (check for dev_load() in net/core/dev.c).172 * I can think of other similar scenario, but they are less common...173 * Jean II */174 166 #endif 175 176 sock_fd = socket(AF_INET, SOCK_DGRAM, 0); 177 if (sock_fd >= 0) { 178 struct ifreq ifr; 179 int tmp; 180 181 strncpy_IFNAMSIZ(ifr.ifr_name, name); 182 ifr.ifr_ifindex = -1; 183 tmp = ioctl(sock_fd, SIOCGIFINDEX, &ifr); 184 close(sock_fd); 185 if (tmp >= 0) 186 /* In theory, we should redump the interface list 187 * to update our cache, this is left as an exercise 188 * to the reader... Jean II */ 189 ret = ifr.ifr_ifindex; 190 } 167 ret = if_nametoindex(name); 191 168 /* out:*/ 192 169 if (ret <= 0)
Note:
See TracChangeset
for help on using the changeset viewer.