Merge commit 'origin/ctrix' into k
[sliver-openvswitch.git] / vswitchd / port.c
1 /* Copyright (c) 2009 Nicira Networks
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #include <config.h>
17
18 #include "bridge.h"
19 #include "cfg.h"
20 #include "netdev.h"
21 #include "ovs-vswitchd.h"
22 #include "port.h"
23 #include "svec.h"
24
25 #define THIS_MODULE VLM_port
26 #include "vlog.h"
27
28 static int
29 set_ingress_policing(const char *port_name) 
30 {
31     int kbits_rate = cfg_get_int(0, "port.%s.ingress.policing-rate", 
32             port_name);
33     int kbits_burst = cfg_get_int(0, "port.%s.ingress.policing-burst", 
34             port_name);
35
36     return netdev_nodev_set_policing(port_name, kbits_rate, kbits_burst);
37 }
38
39 void
40 port_init(void)
41 {
42     port_reconfigure();
43 }
44
45 void
46 port_reconfigure(void)
47 {
48     struct svec ports;
49     int i;
50
51     svec_init(&ports);
52     bridge_get_ifaces(&ports);
53     for (i=0; i<ports.n; i++) {
54         set_ingress_policing(ports.names[i]);
55     }
56 }