[ipxe-devel] [PATCH] [mcurses] Fix GCC 6 nonnull-compare errors.

2016-04-15 Thread Vinson Lee
Remove null checks for arguments declared as nonnull.

  [BUILD] bin/windows.o
hci/mucurses/windows.c: In function ‘delwin’:
hci/mucurses/windows.c:21:5: error: nonnull argument ‘win’ compared to NULL 
[-Werror=nonnull-compare]
  if ( win == NULL )
 ^
hci/mucurses/windows.c: In function ‘derwin’:
hci/mucurses/windows.c:54:5: error: nonnull argument ‘parent’ compared to NULL 
[-Werror=nonnull-compare]
  if ( parent == NULL )
 ^
hci/mucurses/windows.c: In function ‘dupwin’:
hci/mucurses/windows.c:78:5: error: nonnull argument ‘orig’ compared to NULL 
[-Werror=nonnull-compare]
  if ( orig == NULL )
 ^
hci/mucurses/windows.c: In function ‘mvwin’:
hci/mucurses/windows.c:102:5: error: nonnull argument ‘win’ compared to NULL 
[-Werror=nonnull-compare]
  if ( win == NULL )
 ^
hci/mucurses/windows.c: In function ‘subwin’:
hci/mucurses/windows.c:152:5: error: nonnull argument ‘parent’ compared to NULL 
[-Werror=nonnull-compare]
  if ( parent == NULL )
 ^

Fixes: d39e79248c2d ("__nonnull changes")
Signed-off-by: Vinson Lee 
---
 src/hci/mucurses/windows.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/src/hci/mucurses/windows.c b/src/hci/mucurses/windows.c
index 7f39bdea2b7d..5f5d1f4e2a16 100644
--- a/src/hci/mucurses/windows.c
+++ b/src/hci/mucurses/windows.c
@@ -18,9 +18,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  * @ret rc return status code
  */
 int delwin ( WINDOW *win ) {
-   if ( win == NULL )
-   return ERR;
-
/* I think we should blank the region covered by the window -
   ncurses doesn't do this, but they have a buffer, so they
   may just be deleting from an offscreen context whereas we
@@ -51,8 +48,6 @@ int delwin ( WINDOW *win ) {
 WINDOW *derwin ( WINDOW *parent, int nlines, int ncols,
 int begin_y, int begin_x ) {
WINDOW *child;
-   if ( parent == NULL )
-   return NULL;
if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
return NULL;
if ( ( (unsigned)ncols > parent->width ) || 
@@ -75,8 +70,6 @@ WINDOW *derwin ( WINDOW *parent, int nlines, int ncols,
  */
 WINDOW *dupwin ( WINDOW *orig ) {
WINDOW *copy;
-   if ( orig == NULL )
-   return NULL;
if ( ( copy = malloc( sizeof( WINDOW ) ) ) == NULL )
return NULL;
copy->scr = orig->scr;
@@ -99,8 +92,6 @@ WINDOW *dupwin ( WINDOW *orig ) {
  * @ret rc return status code
  */
 int mvwin ( WINDOW *win, int y, int x ) {
-   if ( win == NULL )
-   return ERR;
if ( ( ( (unsigned)y + win->height ) > LINES ) ||
 ( ( (unsigned)x + win->width ) > COLS ) )
return ERR;
@@ -149,8 +140,6 @@ WINDOW *newwin ( int nlines, int ncols, int begin_y, int 
begin_x ) {
 WINDOW *subwin ( WINDOW *parent, int nlines, int ncols,
 int begin_y, int begin_x ) {
WINDOW *child;
-   if ( parent == NULL )
-   return NULL;
if ( ( child = malloc( sizeof( WINDOW ) ) ) == NULL )
return NULL;
child = newwin( nlines, ncols, begin_y, begin_x );
-- 
2.7.1

___
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel


Re: [ipxe-devel] [PATCH 0/2] [vlan] Support 802.1Q VLAN 0 priority tagging

2016-04-15 Thread Michael Brown

On 15/04/16 17:48, Michael Brown wrote:

On 15/04/16 17:19, Ladi Prosek wrote:

These patches add a small tweak to vlan_rx to make it accept
priority tagged packets. Since this should be supported even
without full VLAN support,


Why must this be supported when VLAN is not enabled as a feature?


I have a preference for a simpler patch such as:

diff --git a/src/net/vlan.c b/src/net/vlan.c
index f515c2d..a30a0d7 100644
--- a/src/net/vlan.c
+++ b/src/net/vlan.c
@@ -203,6 +203,11 @@ struct net_device * vlan_find ( struct net_device 
*trunk, unsigned int tag ) {

struct net_device *netdev;
struct vlan_device *vlan;

+   /* VLAN 0 represents a priority-tagged packet on the trunk device */
+   if ( ! tag )
+   return trunk;
+
+   /* Find VLAN device */
for_each_netdev ( netdev ) {
if ( netdev->op != &vlan_operations )
continue;
@@ -340,6 +346,12 @@ int vlan_create ( struct net_device *trunk, 
unsigned int tag,

struct vlan_device *vlan;
int rc;

+   /* VLAN 0 is not permitted */
+   if ( ! tag ) {
+   DBGC ( trunk, "VLAN %s cannot create VLAN 0\n", trunk->name );
+   return -ENOTTY;
+   }
+
/* If VLAN already exists, just update the priority */
if ( ( netdev = vlan_find ( trunk, tag ) ) != NULL ) {
vlan = netdev->priv;


but I'm prepared to be swayed if there are good reasons otherwise.

Michael
___
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel


Re: [ipxe-devel] [PATCH 0/2] [vlan] Support 802.1Q VLAN 0 priority tagging

2016-04-15 Thread Michael Brown

On 15/04/16 17:19, Ladi Prosek wrote:

These patches add a small tweak to vlan_rx to make it accept
priority tagged packets. Since this should be supported even
without full VLAN support,


Why must this be supported when VLAN is not enabled as a feature?

Michael
___
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel


Re: [ipxe-devel] [PATCH v4 0/4] Implement virtio 1.0 support

2016-04-15 Thread Michael Brown

On 12/04/16 14:54, Michael Brown wrote:

On 11/04/16 14:00, Michael S. Tsirkin wrote:

On Mon, Apr 11, 2016 at 11:26:55AM +0200, Ladi Prosek wrote:

The goal here is to support booting from modern and transitional
virtio-net devices using the new virtio 1.0 protocol. The code
strives to comply with the virtio 1.0 spec and is heavily inspired
by the Linux kernel implementation.


series:

Reviewed-by: Michael S. Tsirkin 


Thank you to everyone for all the reviews on this patch series.  Will
merge this version unless there are any further comments in the next day
or so.


Applied, with minor fix to avoid breaking 64-bit builds.  Thank you!

Michael
___
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel


[ipxe-devel] [PATCH 1/2] [vlan] Move vlan_protocol to a separate file

2016-04-15 Thread Ladi Prosek
This commit splits VLAN functionality into protocol / inbound in
vlan_protocol.c and driver / outbound in vlan.c to make adding
support for VLAN 0 priority tagging easier.

Signed-off-by: Ladi Prosek 
---
 src/include/ipxe/errfile.h |   1 +
 src/net/vlan.c |  76 ++
 src/net/vlan_protocol.c| 114 +
 3 files changed, 118 insertions(+), 73 deletions(-)
 create mode 100644 src/net/vlan_protocol.c

diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index 338ebdd..d51467c 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -262,6 +262,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define ERRFILE_peerblk( ERRFILE_NET | 0x0046 )
 #define ERRFILE_peermux( ERRFILE_NET | 0x0047 )
 #define ERRFILE_xsigo  ( ERRFILE_NET | 0x0048 )
+#define ERRFILE_vlan_protocol  ( ERRFILE_NET | 0x0049 )
 
 #define ERRFILE_image( ERRFILE_IMAGE | 0x )
 #define ERRFILE_elf  ( ERRFILE_IMAGE | 0x0001 )
diff --git a/src/net/vlan.c b/src/net/vlan.c
index f515c2d..cc9bb51 100644
--- a/src/net/vlan.c
+++ b/src/net/vlan.c
@@ -214,79 +214,6 @@ struct net_device * vlan_find ( struct net_device *trunk, 
unsigned int tag ) {
 }
 
 /**
- * Process incoming VLAN packet
- *
- * @v iobufI/O buffer
- * @v trunkTrunk network device
- * @v ll_dest  Link-layer destination address
- * @v ll_sourceLink-layer source address
- * @v flagsPacket flags
- * @ret rc Return status code
- */
-static int vlan_rx ( struct io_buffer *iobuf, struct net_device *trunk,
-const void *ll_dest, const void *ll_source,
-unsigned int flags __unused ) {
-   struct vlan_header *vlanhdr = iobuf->data;
-   struct net_device *netdev;
-   struct ll_protocol *ll_protocol;
-   uint8_t ll_dest_copy[ETH_ALEN];
-   uint8_t ll_source_copy[ETH_ALEN];
-   uint16_t tag;
-   int rc;
-
-   /* Sanity check */
-   if ( iob_len ( iobuf ) < sizeof ( *vlanhdr ) ) {
-   DBGC ( trunk, "VLAN %s received underlength packet (%zd "
-  "bytes)\n", trunk->name, iob_len ( iobuf ) );
-   rc = -EINVAL;
-   goto err_sanity;
-   }
-
-   /* Identify VLAN device */
-   tag = VLAN_TAG ( ntohs ( vlanhdr->tci ) );
-   netdev = vlan_find ( trunk, tag );
-   if ( ! netdev ) {
-   DBGC2 ( trunk, "VLAN %s received packet for unknown VLAN "
-   "%d\n", trunk->name, tag );
-   rc = -EPIPE;
-   goto err_no_vlan;
-   }
-
-   /* Strip VLAN header and preserve original link-layer header fields */
-   iob_pull ( iobuf, sizeof ( *vlanhdr ) );
-   ll_protocol = trunk->ll_protocol;
-   memcpy ( ll_dest_copy, ll_dest, ETH_ALEN );
-   memcpy ( ll_source_copy, ll_source, ETH_ALEN );
-
-   /* Reconstruct link-layer header for VLAN device */
-   ll_protocol = netdev->ll_protocol;
-   if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest_copy,
-   ll_source_copy,
-   vlanhdr->net_proto ) ) != 0 ) {
-   DBGC ( netdev, "VLAN %s could not reconstruct link-layer "
-  "header: %s\n", netdev->name, strerror ( rc ) );
-   goto err_ll_push;
-   }
-
-   /* Enqueue packet on VLAN device */
-   netdev_rx ( netdev, iob_disown ( iobuf ) );
-   return 0;
-
- err_ll_push:
- err_no_vlan:
- err_sanity:
-   free_iob ( iobuf );
-   return rc;
-}
-
-/** VLAN protocol */
-struct net_protocol vlan_protocol __net_protocol = {
-   .name = "VLAN",
-   .net_proto = htons ( ETH_P_8021Q ),
-   .rx = vlan_rx,
-};
-
-/**
  * Get the VLAN tag
  *
  * @v netdev   Network device
@@ -506,3 +433,6 @@ struct net_driver vlan_driver __net_driver = {
.notify = vlan_notify,
.remove = vlan_remove,
 };
+
+REQUIRING_SYMBOL ( vlan_driver );
+REQUIRE_OBJECT ( vlan_protocol );
diff --git a/src/net/vlan_protocol.c b/src/net/vlan_protocol.c
new file mode 100644
index 000..3b41cee
--- /dev/null
+++ b/src/net/vlan_protocol.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 Michael Brown .
+ *
+ * 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 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
+

[ipxe-devel] [PATCH 0/2] [vlan] Support 802.1Q VLAN 0 priority tagging

2016-04-15 Thread Ladi Prosek
These patches add a small tweak to vlan_rx to make it accept
priority tagged packets. Since this should be supported even
without full VLAN support, extra care is taken to not drag
any unnecessary code into the build if VLAN_CMD is not enabled.

 src/config/config.c|   7 +++
 src/config/general.h   |   6 +++
 src/include/ipxe/errfile.h |   1 +
 src/net/vlan.c |  76 ++--
 src/net/vlan_protocol.c| 122 +
 5 files changed, 139 insertions(+), 73 deletions(-)

[PATCH 1/2] [vlan] Move vlan_protocol to a separate file
[PATCH 2/2] [vlan] Support VLAN 0 priority tagging
___
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel


[ipxe-devel] [PATCH 2/2] [vlan] Support VLAN 0 priority tagging

2016-04-15 Thread Ladi Prosek
iPXE was unable to receive 802.1Q priority tagged packets even
with VLAN support turned on. These packets are specified in the
802.1Q standard and are supported by all major networking stacks.

With this commit the 802.1Q header is simply stripped off and
the packet is forwarded to a protocol based on the now off-set
EtherType field. For maximum compatibility this is done only
if VLAN 0 has not been explicitly configured.

A new config option VLAN0_PRIORITY is added and enabled in all
builds by default.

Signed-off-by: Ladi Prosek 
---
 src/config/config.c |  7 +++
 src/config/general.h|  6 ++
 src/net/vlan_protocol.c | 16 
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/config/config.c b/src/config/config.c
index 6f9e66c..1094c1b 100644
--- a/src/config/config.c
+++ b/src/config/config.c
@@ -344,3 +344,10 @@ REQUIRE_OBJECT ( vram_settings );
 #define REQUIRE_KEYMAP_OBJECT( _map ) REQUIRE_OBJECT ( keymap_ ## _map )
 #define REQUIRE_KEYMAP( _map ) REQUIRE_KEYMAP_OBJECT ( _map )
 REQUIRE_KEYMAP ( KEYBOARD_MAP );
+
+/*
+ * Drag in vlan_protocol for VLAN 0 priority tagging support
+ */
+ #ifdef VLAN0_PRIORITY
+ REQUIRE_OBJECT ( vlan_protocol );
+ #endif
diff --git a/src/config/general.h b/src/config/general.h
index 675c11e..b6c1189 100644
--- a/src/config/general.h
+++ b/src/config/general.h
@@ -168,6 +168,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #undef ERRMSG_80211/* All 802.11 error descriptions (~3.3kb) */
 
 /*
+ * Support VLAN 0 priority tagged packets even if VLAN_CMD is not defined
+ *
+ */
+#define VLAN0_PRIORITY
+
+/*
  * Obscure configuration options
  *
  * You probably don't need to touch these.
diff --git a/src/net/vlan_protocol.c b/src/net/vlan_protocol.c
index 3b41cee..8ea1c52 100644
--- a/src/net/vlan_protocol.c
+++ b/src/net/vlan_protocol.c
@@ -72,11 +72,19 @@ static int vlan_rx ( struct io_buffer *iobuf, struct 
net_device *trunk,
/* Identify VLAN device */
tag = VLAN_TAG ( ntohs ( vlanhdr->tci ) );
netdev = vlan_find ( trunk, tag );
+
if ( ! netdev ) {
-   DBGC2 ( trunk, "VLAN %s received packet for unknown VLAN "
-   "%d\n", trunk->name, tag );
-   rc = -EPIPE;
-   goto err_no_vlan;
+   if ( tag == 0 ) {
+   /* This is a VLAN 0 priority tagged packet, deliver it
+* to the trunk device.
+*/
+netdev = trunk;
+   } else {
+   DBGC2 ( trunk, "VLAN %s received packet for unknown 
VLAN "
+   "%d\n", trunk->name, tag );
+   rc = -EPIPE;
+   goto err_no_vlan;
+   }
}
 
/* Strip VLAN header and preserve original link-layer header fields */
-- 
2.5.5

___
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel