summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/netdevice.c34
-rw-r--r--src/net/vlan.c47
2 files changed, 73 insertions, 8 deletions
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 71a37eccc..3b02e64bd 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -1126,15 +1126,35 @@ __weak unsigned int vlan_tag ( struct net_device *netdev __unused ) {
}
/**
- * Identify VLAN device (when VLAN support is not present)
+ * Add VLAN tag-stripped packet to queue (when VLAN support is not present)
*
- * @v trunk Trunk network device
- * @v tag VLAN tag
- * @ret netdev VLAN device, if any
+ * @v netdev Network device
+ * @v tag VLAN tag, or zero
+ * @v iobuf I/O buffer
*/
-__weak struct net_device * vlan_find ( struct net_device *trunk __unused,
- unsigned int tag __unused ) {
- return NULL;
+__weak void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
+ struct io_buffer *iobuf ) {
+
+ if ( tag == 0 ) {
+ netdev_rx ( netdev, iobuf );
+ } else {
+ netdev_rx_err ( netdev, iobuf, -ENODEV );
+ }
+}
+
+/**
+ * Discard received VLAN tag-stripped packet (when VLAN support is not present)
+ *
+ * @v netdev Network device
+ * @v tag VLAN tag, or zero
+ * @v iobuf I/O buffer, or NULL
+ * @v rc Packet status code
+ */
+__weak void vlan_netdev_rx_err ( struct net_device *netdev,
+ unsigned int tag __unused,
+ struct io_buffer *iobuf, int rc ) {
+
+ netdev_rx_err ( netdev, iobuf, rc );
}
/** Networking stack process */
diff --git a/src/net/vlan.c b/src/net/vlan.c
index f515c2dc9..90f2934de 100644
--- a/src/net/vlan.c
+++ b/src/net/vlan.c
@@ -199,7 +199,8 @@ static void vlan_sync ( struct net_device *netdev ) {
* @v tag VLAN tag
* @ret netdev VLAN device, if any
*/
-struct net_device * vlan_find ( struct net_device *trunk, unsigned int tag ) {
+static struct net_device * vlan_find ( struct net_device *trunk,
+ unsigned int tag ) {
struct net_device *netdev;
struct vlan_device *vlan;
@@ -506,3 +507,47 @@ struct net_driver vlan_driver __net_driver = {
.notify = vlan_notify,
.remove = vlan_remove,
};
+
+/**
+ * Add VLAN tag-stripped packet to receive queue
+ *
+ * @v netdev Network device
+ * @v tag VLAN tag, or zero
+ * @v iobuf I/O buffer
+ */
+void vlan_netdev_rx ( struct net_device *netdev, unsigned int tag,
+ struct io_buffer *iobuf ) {
+ struct net_device *vlan;
+
+ /* Identify VLAN device, if applicable */
+ if ( tag ) {
+ if ( ( vlan = vlan_find ( netdev, tag ) ) == NULL ) {
+ netdev_rx_err ( netdev, iobuf, -ENODEV );
+ return;
+ }
+ netdev = vlan;
+ }
+
+ /* Hand off to network device */
+ netdev_rx ( netdev, iobuf );
+}
+
+/**
+ * Discard received VLAN tag-stripped packet
+ *
+ * @v netdev Network device
+ * @v tag VLAN tag, or zero
+ * @v iobuf I/O buffer, or NULL
+ * @v rc Packet status code
+ */
+void vlan_netdev_rx_err ( struct net_device *netdev, unsigned int tag,
+ struct io_buffer *iobuf, int rc ) {
+ struct net_device *vlan;
+
+ /* Identify VLAN device, if applicable */
+ if ( tag && ( ( vlan = vlan_find ( netdev, tag ) ) != NULL ) )
+ netdev = vlan;
+
+ /* Hand off to network device */
+ netdev_rx_err ( netdev, iobuf, rc );
+}