For SNAT, don't store the pre-fragment L2 header before actions are applied.
[sliver-openvswitch.git] / datapath / dp_notify.c
1 /*
2  * Distributed under the terms of the GNU GPL version 2.
3  * Copyright (c) 2007, 2008 The Board of Trustees of The Leland 
4  * Stanford Junior University
5  */
6
7 /* Handle changes to managed devices */
8
9 #include <linux/netdevice.h>
10
11 #include "datapath.h"
12
13
14 static int dp_device_event(struct notifier_block *unused, unsigned long event, 
15                 void *ptr) 
16 {
17         struct net_device *dev = ptr;
18         struct net_bridge_port *p = dev->br_port;
19         unsigned long int flags;
20         uint32_t orig_state, orig_config;
21
22
23         /* Check if monitored port */
24         if (!p)
25                 return NOTIFY_DONE;
26
27         spin_lock_irqsave(&p->lock, flags);
28         orig_state = p->state;
29         orig_config = p->config;
30
31         switch (event) {
32                 case NETDEV_CHANGE:
33                         if (netif_carrier_ok(p->dev))
34                                 p->state &= ~OFPPS_LINK_DOWN;
35                         else
36                                 p->state |= OFPPS_LINK_DOWN;
37                         break;
38
39                 case NETDEV_DOWN:
40                         p->config |= OFPPC_PORT_DOWN;
41                         break;
42
43                 case NETDEV_UP:
44                         p->config &= ~OFPPC_PORT_DOWN;
45                         break;
46
47                 case NETDEV_UNREGISTER:
48                         spin_unlock_irqrestore(&p->lock, flags);
49                         dp_del_switch_port(p);
50                         return NOTIFY_DONE;
51                         break;
52         }
53         spin_unlock_irqrestore(&p->lock, flags);
54
55         if ((orig_state != p->state) || (orig_config != p->config))
56                 dp_send_port_status(p, OFPPR_MODIFY);
57
58         return NOTIFY_DONE;
59 }
60
61 struct notifier_block dp_device_notifier = {
62         .notifier_call = dp_device_event
63 };