Skip to content

Commit abab733

Browse files
author
David Sommerseth
committed
Rip out the old IPv6 implementation completely
The whole IPv6 support will be re-implemented using a simliar strategy as the newer IPv4 support uses. Signed-off-by: David Sommerseth <davids@redhat.com>
1 parent d9922c0 commit abab733

File tree

7 files changed

+3
-462
lines changed

7 files changed

+3
-462
lines changed

python-ethtool/etherinfo.c

Lines changed: 2 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,8 @@ pthread_mutex_t nlc_counter_mtx = PTHREAD_MUTEX_INITIALIZER;
6161
dst = strdup(src); \
6262
}
6363

64-
65-
/**
66-
* Frees the memory used by a struct ipv6address pointer chain. All elements are freed
67-
*
68-
* @param ptr Pointer to a struct ipv6address chain.
69-
*/
70-
void free_ipv6addresses(struct ipv6address *ptr) {
71-
struct ipv6address *ipv6ptr = ptr;
72-
73-
while( ipv6ptr ) {
74-
struct ipv6address *tmp = ipv6ptr->next;
75-
76-
if( ipv6ptr->address ) {
77-
free(ipv6ptr->address);
78-
ipv6ptr->address = NULL;
79-
}
80-
memset(ipv6ptr, 0, sizeof(struct ipv6address));
81-
free(ipv6ptr);
82-
ipv6ptr = tmp;
83-
}
84-
}
85-
8664
/**
87-
* Frees the memory used by struct etherinfo, including all struct ipv6address children.
65+
* Frees the memory used by struct etherinfo
8866
*
8967
* @param ptr Pointer to a struct etherninfo element
9068
*/
@@ -101,51 +79,10 @@ void free_etherinfo(struct etherinfo *ptr)
10179
}
10280
Py_XDECREF(ptr->ipv4_addresses);
10381

104-
if( ptr->ipv6_addresses ) {
105-
free_ipv6addresses(ptr->ipv6_addresses);
106-
}
10782
free(ptr);
10883
}
10984

11085

111-
/**
112-
* Add a new IPv6 address record to a struct ipv6address chain
113-
*
114-
* @param addrptr Pointer to the current IPv6 address chain.
115-
* @param addr IPv6 address, represented as char * string
116-
* @param netmask IPv6 netmask, as returned by libnl rtnl_addr_get_prefixlen()
117-
* @param scope IPV6 address scope, as returned by libnl rtnl_addr_get_scope()
118-
*
119-
* @return Returns a new pointer to the chain containing the new element
120-
*/
121-
struct ipv6address * etherinfo_add_ipv6(struct ipv6address *addrptr, struct rtnl_addr *addr) {
122-
struct ipv6address *newaddr = NULL;
123-
char buf[INET6_ADDRSTRLEN+2];
124-
int af_family;
125-
126-
af_family = rtnl_addr_get_family(addr);
127-
if( af_family != AF_INET && af_family != AF_INET6 ) {
128-
return addrptr;
129-
}
130-
131-
memset(&buf, 0, sizeof(buf));
132-
inet_ntop(af_family, nl_addr_get_binary_addr(rtnl_addr_get_local(addr)), buf, sizeof(buf));
133-
134-
newaddr = calloc(1, sizeof(struct ipv6address)+2);
135-
if( !newaddr ) {
136-
fprintf(stderr, "** ERROR ** Could not allocate memory for a new IPv6 address record (%s/%i [%i])",
137-
buf, rtnl_addr_get_prefixlen(addr), rtnl_addr_get_scope(addr));
138-
return addrptr;
139-
}
140-
141-
SET_STR_VALUE(newaddr->address, buf);
142-
newaddr->netmask = rtnl_addr_get_prefixlen(addr);
143-
newaddr->scope = rtnl_addr_get_scope(addr);
144-
newaddr->next = addrptr;
145-
return newaddr;
146-
}
147-
148-
14986
/**
15087
* libnl callback function. Does the real parsing of a record returned by NETLINK. This function
15188
* parses LINK related packets
@@ -218,9 +155,6 @@ static void callback_nl_address(struct nl_object *obj, void *arg)
218155
case AF_INET:
219156
append_object_for_netlink_address(ethi, rtaddr);
220157
return;
221-
case AF_INET6:
222-
ethi->ipv6_addresses = etherinfo_add_ipv6(ethi->ipv6_addresses, rtaddr);
223-
return;
224158
default:
225159
return;
226160
}
@@ -234,48 +168,6 @@ static void callback_nl_address(struct nl_object *obj, void *arg)
234168
*
235169
*/
236170

237-
/**
238-
* Dumps the contents of a struct etherinfo element to file
239-
*
240-
* @param fp FILE pointer where to dump
241-
* @param ptr Pointer to a struct etherinfo element
242-
*/
243-
void dump_etherinfo(FILE *fp, struct etherinfo *ptr)
244-
{
245-
246-
fprintf(fp, "*** Interface [%i] %s ", ptr->index, ptr->device);
247-
if( ptr->hwaddress ) {
248-
fprintf(fp, "MAC address: %s", ptr->hwaddress);
249-
}
250-
fprintf(fp, "\n");
251-
if( ptr->ipv4_addresses ) {
252-
Py_ssize_t i;
253-
for (i = 0; i < PyList_Size(ptr->ipv4_addresses); i++) {
254-
PyNetlinkIPv4Address *addr = (PyNetlinkIPv4Address *)PyList_GetItem(ptr->ipv4_addresses, i);
255-
fprintf(fp, "\tIPv4 Address: %s/%i",
256-
PyString_AsString(addr->ipv4_address),
257-
addr->ipv4_netmask);
258-
if( addr->ipv4_broadcast ) {
259-
fprintf(fp, " - Broadcast: %s", PyString_AsString(addr->ipv4_broadcast));
260-
}
261-
fprintf(fp, "\n");
262-
}
263-
}
264-
if( ptr->ipv6_addresses ) {
265-
struct ipv6address *ipv6 = ptr->ipv6_addresses;
266-
267-
fprintf(fp, "\tIPv6 addresses:\n");
268-
for(; ipv6; ipv6 = ipv6->next) {
269-
char scope[66];
270-
271-
rtnl_scope2str(ipv6->scope, scope, 64);
272-
fprintf(fp, "\t [%s] %s/%i\n",
273-
scope, ipv6->address, ipv6->netmask);
274-
}
275-
}
276-
fprintf(fp, "\n");
277-
}
278-
279171

280172
/**
281173
* Query NETLINK for ethernet configuration
@@ -353,13 +245,7 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
353245
addr = rtnl_addr_alloc();
354246
rtnl_addr_set_ifindex(addr, ethinf->index);
355247

356-
/* Make sure we don't have any old IPv6 addresses saved */
357-
if( ethinf->ipv6_addresses ) {
358-
free_ipv6addresses(ethinf->ipv6_addresses);
359-
ethinf->ipv6_addresses = NULL;
360-
}
361-
362-
/* Likewise for IPv4 addresses: */
248+
/* Make sure we don't have any old IPv4 addresses saved */
363249
Py_XDECREF(ethinf->ipv4_addresses);
364250
ethinf->ipv4_addresses = PyList_New(0);
365251
if (!ethinf->ipv4_addresses) {

python-ethtool/etherinfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ typedef enum {NLQRY_LINK, NLQRY_ADDR} nlQuery; /**< Supported query types in th
2121

2222
int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query);
2323
void free_etherinfo(struct etherinfo *ptr);
24-
void dump_etherinfo(FILE *, struct etherinfo *);
25-
26-
void free_ipv6addresses(struct ipv6address *ptr);
2724

2825
int open_netlink(struct etherinfo_obj_data *);
2926
void close_netlink(struct etherinfo_obj_data *);

python-ethtool/etherinfo_ipv6_obj.c

Lines changed: 0 additions & 230 deletions
This file was deleted.

0 commit comments

Comments
 (0)