Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[cascardo/ovs.git] / vswitchd / port.c
1 /* Copyright (c) 2009 Nicira Networks
2  * 
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  * In addition, as a special exception, Nicira Networks gives permission
17  * to link the code of its release of vswitchd with the OpenSSL project's
18  * "OpenSSL" library (or with modified versions of it that use the same
19  * license as the "OpenSSL" library), and distribute the linked
20  * executables.  You must obey the GNU General Public License in all
21  * respects for all of the code used other than "OpenSSL".  If you modify
22  * this file, you may extend this exception to your version of the file,
23  * but you are not obligated to do so.  If you do not wish to do so,
24  * delete this exception statement from your version.
25  *
26  */
27
28 #include <config.h>
29
30 #include "bridge.h"
31 #include "cfg.h"
32 #include "netdev.h"
33 #include "ovs-vswitchd.h"
34 #include "port.h"
35 #include "svec.h"
36
37 #define THIS_MODULE VLM_port
38 #include "vlog.h"
39
40 static int
41 set_ingress_policing(const char *port_name) 
42 {
43     int kbits_rate = cfg_get_int(0, "port.%s.ingress.policing-rate", 
44             port_name);
45     int kbits_burst = cfg_get_int(0, "port.%s.ingress.policing-burst", 
46             port_name);
47
48     return netdev_nodev_set_policing(port_name, kbits_rate, kbits_burst);
49 }
50
51 void
52 port_init(void)
53 {
54     port_reconfigure();
55 }
56
57 void
58 port_reconfigure(void)
59 {
60     struct svec ports;
61     int i;
62
63     svec_init(&ports);
64     bridge_get_ifaces(&ports);
65     for (i=0; i<ports.n; i++) {
66         set_ingress_policing(ports.names[i]);
67     }
68 }