| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xennetback_xenbus.c,v 1.34 2010/04/05 07:19:32 joerg Exp $ */ | | 1 | /* $NetBSD: xennetback_xenbus.c,v 1.35 2011/01/08 05:23:19 jym Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2006 Manuel Bouyer. | | 4 | * Copyright (c) 2006 Manuel Bouyer. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -261,50 +261,50 @@ xennetback_xenbus_create(struct xenbus_d | | | @@ -261,50 +261,50 @@ xennetback_xenbus_create(struct xenbus_d |
261 | if (xneti == NULL) { | | 261 | if (xneti == NULL) { |
262 | return ENOMEM; | | 262 | return ENOMEM; |
263 | } | | 263 | } |
264 | xneti->xni_domid = domid; | | 264 | xneti->xni_domid = domid; |
265 | xneti->xni_handle = handle; | | 265 | xneti->xni_handle = handle; |
266 | xneti->xni_status = DISCONNECTED; | | 266 | xneti->xni_status = DISCONNECTED; |
267 | | | 267 | |
268 | xbusd->xbusd_u.b.b_cookie = xneti; | | 268 | xbusd->xbusd_u.b.b_cookie = xneti; |
269 | xbusd->xbusd_u.b.b_detach = xennetback_xenbus_destroy; | | 269 | xbusd->xbusd_u.b.b_detach = xennetback_xenbus_destroy; |
270 | xneti->xni_xbusd = xbusd; | | 270 | xneti->xni_xbusd = xbusd; |
271 | | | 271 | |
272 | ifp = &xneti->xni_if; | | 272 | ifp = &xneti->xni_if; |
273 | ifp->if_softc = xneti; | | 273 | ifp->if_softc = xneti; |
| | | 274 | snprintf(ifp->if_xname, IFNAMSIZ, "xvif%d.%d", |
| | | 275 | (int)domid, (int)handle); |
274 | | | 276 | |
275 | /* read mac address */ | | 277 | /* read mac address */ |
276 | if ((err = xenbus_read(NULL, xbusd->xbusd_path, "mac", NULL, &val))) { | | 278 | if ((err = xenbus_read(NULL, xbusd->xbusd_path, "mac", NULL, &val))) { |
277 | aprint_error("xvif: can' read %s/mac: %d\n", | | 279 | aprint_error_ifnet(ifp, "can't read %s/mac: %d\n", |
278 | xbusd->xbusd_path, err); | | 280 | xbusd->xbusd_path, err); |
279 | goto fail; | | 281 | goto fail; |
280 | } | | 282 | } |
281 | for (i = 0, p = val; i < 6; i++) { | | 283 | for (i = 0, p = val; i < 6; i++) { |
282 | xneti->xni_enaddr[i] = strtoul(p, &e, 16); | | 284 | xneti->xni_enaddr[i] = strtoul(p, &e, 16); |
283 | if ((e[0] == '\0' && i != 5) && e[0] != ':') { | | 285 | if ((e[0] == '\0' && i != 5) && e[0] != ':') { |
284 | aprint_error("xvif: %s is not a valid mac address\n", | | 286 | aprint_error_ifnet(ifp, |
285 | val); | | 287 | "%s is not a valid mac address\n", val); |
286 | err = EINVAL; | | 288 | err = EINVAL; |
287 | goto fail; | | 289 | goto fail; |
288 | } | | 290 | } |
289 | p = &e[1]; | | 291 | p = &e[1]; |
290 | } | | 292 | } |
291 | free(val, M_DEVBUF); | | 293 | free(val, M_DEVBUF); |
292 | | | 294 | |
293 | /* we can't use the same MAC addr as our guest */ | | 295 | /* we can't use the same MAC addr as our guest */ |
294 | xneti->xni_enaddr[3]++; | | 296 | xneti->xni_enaddr[3]++; |
295 | /* create pseudo-interface */ | | 297 | /* create pseudo-interface */ |
296 | snprintf(xneti->xni_if.if_xname, IFNAMSIZ, "xvif%d.%d", | | | |
297 | (int)domid, (int)handle); | | | |
298 | aprint_verbose_ifnet(ifp, "Ethernet address %s\n", | | 298 | aprint_verbose_ifnet(ifp, "Ethernet address %s\n", |
299 | ether_sprintf(xneti->xni_enaddr)); | | 299 | ether_sprintf(xneti->xni_enaddr)); |
300 | ifp->if_flags = | | 300 | ifp->if_flags = |
301 | IFF_BROADCAST|IFF_SIMPLEX|IFF_NOTRAILERS|IFF_MULTICAST; | | 301 | IFF_BROADCAST|IFF_SIMPLEX|IFF_NOTRAILERS|IFF_MULTICAST; |
302 | ifp->if_snd.ifq_maxlen = | | 302 | ifp->if_snd.ifq_maxlen = |
303 | max(ifqmaxlen, NET_TX_RING_SIZE * 2); | | 303 | max(ifqmaxlen, NET_TX_RING_SIZE * 2); |
304 | ifp->if_capabilities = IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_UDPv4_Tx; | | 304 | ifp->if_capabilities = IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_UDPv4_Tx; |
305 | ifp->if_ioctl = xennetback_ifioctl; | | 305 | ifp->if_ioctl = xennetback_ifioctl; |
306 | ifp->if_start = xennetback_ifstart; | | 306 | ifp->if_start = xennetback_ifstart; |
307 | ifp->if_watchdog = xennetback_ifwatchdog; | | 307 | ifp->if_watchdog = xennetback_ifwatchdog; |
308 | ifp->if_init = xennetback_ifinit; | | 308 | ifp->if_init = xennetback_ifinit; |
309 | ifp->if_stop = xennetback_ifstop; | | 309 | ifp->if_stop = xennetback_ifstop; |
310 | ifp->if_timer = 0; | | 310 | ifp->if_timer = 0; |