macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 1 | import logging |
| 2 | |
| 3 | from oftest import config |
| 4 | import oftest.base_tests as base_tests |
| 5 | import ofp |
| 6 | import time |
| 7 | from oftest.testutils import * |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 8 | from oftest.parse import parse_ipv6 |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 9 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 10 | from ncclient import manager |
| 11 | import ncclient |
| 12 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 13 | OFDPA_GROUP_TYPE_SHIFT=28 |
| 14 | OFDPA_VLAN_ID_SHIFT =16 |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 15 | OFDPA_TUNNEL_ID_SHIFT =12 |
| 16 | OFDPA_TUNNEL_SUBTYPE_SHIFT=10 |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 17 | |
| 18 | #VLAN_TABLE_FLAGS |
| 19 | VLAN_TABLE_FLAG_ONLY_UNTAG=1 |
| 20 | VLAN_TABLE_FLAG_ONLY_TAG =2 |
| 21 | VLAN_TABLE_FLAG_ONLY_BOTH =3 |
Pier | e130876 | 2016-09-12 15:29:56 -0700 | [diff] [blame] | 22 | VLAN_TABLE_FLAG_ONLY_STACKED=5 |
| 23 | VLAN_TABLE_FLAG_PRIORITY=6 |
| 24 | VLAN_TABLE_FLAG_ONLY_UNTAG_PRIORITY=7 |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 25 | |
macauley | e8b140e | 2015-08-03 13:35:45 +0800 | [diff] [blame] | 26 | PORT_FLOW_TABLE=0 |
| 27 | VLAN_FLOW_TABLE=10 |
Pier | e130876 | 2016-09-12 15:29:56 -0700 | [diff] [blame] | 28 | VLAN_1_FLOW_TABLE=11 |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 29 | MPLS_L2_PORT_FLOW_TABLE=13 |
| 30 | MPLS_L2_PORT_DSCP_TRUST_FLOW_TABLE=15 |
| 31 | MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE=16 |
macauley | e8b140e | 2015-08-03 13:35:45 +0800 | [diff] [blame] | 32 | TERMINATION_FLOW_TABLE=20 |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 33 | MPLS_TYPE_FLOW_TABLE=29 |
macauley | e8b140e | 2015-08-03 13:35:45 +0800 | [diff] [blame] | 34 | UCAST_ROUTING_FLOW_TABLE=30 |
| 35 | MCAST_ROUTING_FLOW_TABLE=40 |
| 36 | BRIDGE_FLOW_TABLE=50 |
| 37 | ACL_FLOW_TABLE=60 |
| 38 | |
| 39 | def convertIP4toStr(ip_addr): |
| 40 | a=(ip_addr&0xff000000)>>24 |
| 41 | b=(ip_addr&0x00ff0000)>>16 |
| 42 | c=(ip_addr&0x0000ff00)>>8 |
| 43 | d=(ip_addr&0x000000ff) |
| 44 | return str(a)+"."+str(b)+"."+str(c)+"."+str(d) |
| 45 | |
| 46 | def convertMACtoStr(mac): |
| 47 | if not isinstance(mac, list): |
| 48 | assert(0) |
| 49 | |
| 50 | return ':'.join(['%02X' % x for x in mac]) |
| 51 | |
macauley | 7f89d96 | 2015-08-06 18:13:48 +0800 | [diff] [blame] | 52 | def getSwitchCpuMACFromDPID(dpid): |
| 53 | str_datapath_id_f= "{:016x}".format(dpid) |
| 54 | str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)]) |
| 55 | switch_cpu_mac_str=str_datapath_id[6:] |
| 56 | switch_cpu_mac = switch_cpu_mac_str.split(":") |
| 57 | switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))] |
| 58 | |
| 59 | return switch_cpu_mac_str, switch_cpu_mac |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 60 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 61 | def DumpGroup(stats, verify_group_stats, always_show=True): |
| 62 | if(len(stats) > len(verify_group_stats)): |
| 63 | min_len = len(verify_group_stats) |
| 64 | print "Stats Len is not the same, stats>verify_group_stats" |
| 65 | if(len(stats)< len(verify_group_stats)): |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 66 | min_len = len(stats) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 67 | print "Stats Len is not the same, stats<verify_group_stats" |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 68 | else: |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 69 | min_len = len(stats) |
macauley | e8b140e | 2015-08-03 13:35:45 +0800 | [diff] [blame] | 70 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 71 | print "\r\n" |
| 72 | for i in range(min_len): |
| 73 | gs = stats[i] |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 74 | gv = verify_group_stats[i] |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 75 | print "FromSwtich:(GID=%lx, TYPE=%lx)\r\nVerify :(GID=%lx, TYPE=%lx)"%(gs.group_id, gs.group_type, gv.group_id, gv.group_type) |
| 76 | if(len(gs.buckets) != len(gv.buckets)): |
| 77 | print "buckets len is not the same gs %lx, gv %lx",(len(gs.buckets), len(gv.buckets)) |
| 78 | |
| 79 | for j in range(len(gs.buckets)): |
| 80 | b1=gs.buckets[j] |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 81 | b2=gv.buckets[j] |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 82 | if(len(b1.actions) != len(b2.actions)): |
| 83 | print "action len is not the same" |
| 84 | |
| 85 | for k in range(len(b1.actions)): |
| 86 | a1=b1.actions[k] |
| 87 | a2=b2.actions[k] |
| 88 | if(always_show == True): |
| 89 | print "a1:"+a1.show() |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 90 | print "a2:"+a2.show() |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 91 | |
| 92 | def AssertGroup(self, stats, verify_group_stats): |
| 93 | self.assertTrue(len(stats) ==len(verify_group_stats), "stats len is not the same") |
| 94 | |
| 95 | for i in range(len(stats)): |
| 96 | gs = stats[i] |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 97 | gv = verify_group_stats[i] |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 98 | self.assertTrue(len(gs.buckets) == len(gv.buckets), "buckets len is not the same") |
| 99 | |
| 100 | for j in range(len(gs.buckets)): |
| 101 | b1=gs.buckets[j] |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 102 | b2=gv.buckets[j] |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 103 | self.assertTrue(len(b1.actions) == len(b2.actions), "action len is not the same") |
| 104 | |
| 105 | for k in range(len(b1.actions)): |
| 106 | a1=b1.actions[k] |
| 107 | a2=b2.actions[k] |
| 108 | self.assertEquals(a1, a2, "action is not the same") |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 109 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 110 | def encode_l2_interface_group_id(vlan, id): |
| 111 | return id + (vlan << OFDPA_VLAN_ID_SHIFT) |
| 112 | |
| 113 | def encode_l2_rewrite_group_id(id): |
| 114 | return id + (1 << OFDPA_GROUP_TYPE_SHIFT) |
| 115 | |
| 116 | def encode_l3_unicast_group_id(id): |
| 117 | return id + (2 << OFDPA_GROUP_TYPE_SHIFT) |
| 118 | |
| 119 | def encode_l2_mcast_group_id(vlan, id): |
| 120 | return id + (vlan << OFDPA_VLAN_ID_SHIFT) + (3 << OFDPA_GROUP_TYPE_SHIFT) |
| 121 | |
| 122 | def encode_l2_flood_group_id(vlan, id): |
| 123 | return id + (vlan << OFDPA_VLAN_ID_SHIFT) + (4 << OFDPA_GROUP_TYPE_SHIFT) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 124 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 125 | def encode_l3_interface_group_id(id): |
| 126 | return id + (5 << OFDPA_GROUP_TYPE_SHIFT) |
| 127 | |
| 128 | def encode_l3_mcast_group_id(vlan, id): |
| 129 | return id + (vlan << OFDPA_VLAN_ID_SHIFT)+(6 << OFDPA_GROUP_TYPE_SHIFT) |
| 130 | |
| 131 | def encode_l3_ecmp_group_id(id): |
| 132 | return id + (7 << OFDPA_GROUP_TYPE_SHIFT) |
| 133 | |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 134 | def encode_l2_unfiltered_group_id(id): |
| 135 | return id + (11 << OFDPA_GROUP_TYPE_SHIFT) |
| 136 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 137 | def encode_l2_overlay_group_id(tunnel_id, subtype, index): |
| 138 | tunnel_id=tunnel_id&0xffff #16 bits |
| 139 | subtype = subtype&3 #2 bits |
| 140 | index = index & 0x3f #10 bits |
| 141 | return index + (tunnel_id << OFDPA_TUNNEL_ID_SHIFT)+ (subtype<<OFDPA_TUNNEL_SUBTYPE_SHIFT)+(8 << OFDPA_GROUP_TYPE_SHIFT) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 142 | |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 143 | def add_l2_unfiltered_group(ctrl, ports, send_barrier=False): |
| 144 | # group table |
| 145 | # set up untag groups for each port |
| 146 | group_id_list=[] |
| 147 | msgs=[] |
| 148 | for of_port in ports: |
| 149 | # do stuff |
| 150 | group_id = encode_l2_unfiltered_group_id(of_port) |
| 151 | group_id_list.append(group_id) |
| 152 | actions = [ofp.action.output(of_port)] |
| 153 | actions.append(ofp.action.set_field(ofp.oxm.exp1ByteValue(exp_type=24, value=1))) |
| 154 | |
| 155 | buckets = [ofp.bucket(actions=actions)] |
| 156 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 157 | group_id=group_id, |
| 158 | buckets=buckets |
| 159 | ) |
| 160 | ctrl.message_send(request) |
| 161 | msgs.append(request) |
| 162 | |
| 163 | if send_barrier: |
| 164 | do_barrier(ctrl) |
| 165 | |
| 166 | return group_id_list, msgs |
| 167 | |
Pier | f6f2816 | 2016-09-22 16:30:52 -0700 | [diff] [blame] | 168 | def add_one_l2_unfiltered_group(ctrl, of_port, send_barrier=False): |
| 169 | # group table |
| 170 | # set up untag groups for each port |
| 171 | group_id = encode_l2_unfiltered_group_id(of_port) |
| 172 | actions = [ofp.action.output(of_port)] |
| 173 | actions.append(ofp.action.set_field(ofp.oxm.exp1ByteValue(exp_type=24, value=1))) |
| 174 | |
| 175 | buckets = [ofp.bucket(actions=actions)] |
| 176 | request = ofp.message.group_add( |
| 177 | group_type=ofp.OFPGT_INDIRECT, |
| 178 | group_id=group_id, |
| 179 | buckets=buckets |
| 180 | ) |
| 181 | ctrl.message_send(request) |
| 182 | |
| 183 | if send_barrier: |
| 184 | do_barrier(ctrl) |
| 185 | |
| 186 | return group_id, request |
| 187 | |
Flavio Castro | d4c44d1 | 2015-12-08 14:44:18 -0500 | [diff] [blame] | 188 | def add_l2_interface_group(ctrl, ports, vlan_id=1, is_tagged=False, send_barrier=False): |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 189 | # group table |
| 190 | # set up untag groups for each port |
macauley | 41904ed | 2015-07-16 17:38:35 +0800 | [diff] [blame] | 191 | group_id_list=[] |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 192 | msgs=[] |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 193 | for of_port in ports: |
| 194 | # do stuff |
| 195 | group_id = encode_l2_interface_group_id(vlan_id, of_port) |
macauley | 41904ed | 2015-07-16 17:38:35 +0800 | [diff] [blame] | 196 | group_id_list.append(group_id) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 197 | if is_tagged: |
| 198 | actions = [ |
| 199 | ofp.action.output(of_port), |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 200 | ] |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 201 | else: |
| 202 | actions = [ |
| 203 | ofp.action.pop_vlan(), |
| 204 | ofp.action.output(of_port), |
| 205 | ] |
| 206 | |
| 207 | buckets = [ |
| 208 | ofp.bucket(actions=actions), |
| 209 | ] |
| 210 | |
| 211 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 212 | group_id=group_id, |
| 213 | buckets=buckets |
| 214 | ) |
| 215 | ctrl.message_send(request) |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 216 | msgs.append(request) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 217 | |
| 218 | if send_barrier: |
| 219 | do_barrier(ctrl) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 220 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 221 | return group_id_list, msgs |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 222 | |
Flavio Castro | d4c44d1 | 2015-12-08 14:44:18 -0500 | [diff] [blame] | 223 | def add_one_l2_interface_group(ctrl, port, vlan_id=1, is_tagged=False, send_barrier=False): |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 224 | # group table |
| 225 | # set up untag groups for each port |
| 226 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 227 | |
| 228 | if is_tagged: |
| 229 | actions = [ |
| 230 | ofp.action.output(port), |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 231 | ] |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 232 | else: |
| 233 | actions = [ |
| 234 | ofp.action.pop_vlan(), |
| 235 | ofp.action.output(port), |
| 236 | ] |
| 237 | |
| 238 | buckets = [ |
| 239 | ofp.bucket(actions=actions), |
| 240 | ] |
| 241 | |
| 242 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 243 | group_id=group_id, |
| 244 | buckets=buckets |
| 245 | ) |
| 246 | ctrl.message_send(request) |
| 247 | |
| 248 | if send_barrier: |
| 249 | do_barrier(ctrl) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 250 | |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 251 | return group_id, request |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 252 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 253 | def add_l2_mcast_group(ctrl, ports, vlanid, mcast_grp_index): |
| 254 | buckets=[] |
| 255 | for of_port in ports: |
| 256 | group_id = encode_l2_interface_group_id(vlanid, of_port) |
| 257 | action=[ofp.action.group(group_id)] |
| 258 | buckets.append(ofp.bucket(actions=action)) |
| 259 | |
| 260 | group_id =encode_l2_mcast_group_id(vlanid, mcast_grp_index) |
| 261 | request = ofp.message.group_add(group_type=ofp.OFPGT_ALL, |
| 262 | group_id=group_id, |
| 263 | buckets=buckets |
| 264 | ) |
| 265 | ctrl.message_send(request) |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 266 | return request |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 267 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 268 | def add_l2_flood_group(ctrl, ports, vlanid, id): |
| 269 | buckets=[] |
| 270 | for of_port in ports: |
| 271 | group_id = encode_l2_interface_group_id(vlanid, of_port) |
| 272 | action=[ofp.action.group(group_id)] |
| 273 | buckets.append(ofp.bucket(actions=action)) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 274 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 275 | group_id =encode_l2_flood_group_id(vlanid, id) |
| 276 | request = ofp.message.group_add(group_type=ofp.OFPGT_ALL, |
| 277 | group_id=group_id, |
| 278 | buckets=buckets |
| 279 | ) |
| 280 | ctrl.message_send(request) |
| 281 | return request |
| 282 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 283 | def mod_l2_flood_group(ctrl, ports, vlanid, id): |
| 284 | buckets=[] |
| 285 | for of_port in ports: |
| 286 | group_id = encode_l2_interface_group_id(vlanid, of_port) |
| 287 | action=[ofp.action.group(group_id)] |
| 288 | buckets.append(ofp.bucket(actions=action)) |
| 289 | |
| 290 | group_id =encode_l2_flood_group_id(vlanid, id) |
| 291 | request = ofp.message.group_modify(group_type=ofp.OFPGT_ALL, |
| 292 | group_id=group_id, |
| 293 | buckets=buckets |
| 294 | ) |
| 295 | ctrl.message_send(request) |
| 296 | return request |
| 297 | |
| 298 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 299 | def add_l2_rewrite_group(ctrl, port, vlanid, id, src_mac, dst_mac): |
| 300 | group_id = encode_l2_interface_group_id(vlanid, port) |
| 301 | |
| 302 | action=[] |
| 303 | if src_mac is not None: |
| 304 | action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac))) |
| 305 | |
| 306 | if dst_mac is not None: |
| 307 | action.append(ofp.action.set_field(ofp.oxm.eth_dst(dst_mac))) |
| 308 | |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 309 | action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid))) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 310 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 311 | action.append(ofp.action.group(group_id)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 312 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 313 | buckets = [ofp.bucket(actions=action)] |
| 314 | |
| 315 | group_id =encode_l2_rewrite_group_id(id) |
| 316 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 317 | group_id=group_id, |
| 318 | buckets=buckets |
| 319 | ) |
| 320 | ctrl.message_send(request) |
| 321 | return request |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 322 | |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 323 | def add_l3_unicast_group(ctrl, port, vlanid, id, src_mac, dst_mac, send_barrier=False): |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 324 | group_id = encode_l2_interface_group_id(vlanid, port) |
| 325 | |
| 326 | action=[] |
| 327 | if src_mac is not None: |
| 328 | action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac))) |
| 329 | |
| 330 | if dst_mac is not None: |
| 331 | action.append(ofp.action.set_field(ofp.oxm.eth_dst(dst_mac))) |
| 332 | |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 333 | action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid))) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 334 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 335 | action.append(ofp.action.group(group_id)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 336 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 337 | buckets = [ofp.bucket(actions=action)] |
| 338 | |
| 339 | group_id =encode_l3_unicast_group_id(id) |
| 340 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 341 | group_id=group_id, |
| 342 | buckets=buckets |
| 343 | ) |
| 344 | ctrl.message_send(request) |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 345 | |
| 346 | if send_barrier: |
| 347 | do_barrier(ctrl) |
| 348 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 349 | return request |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 350 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 351 | def add_l3_interface_group(ctrl, port, vlanid, id, src_mac): |
| 352 | group_id = encode_l2_interface_group_id(vlanid, port) |
| 353 | |
| 354 | action=[] |
| 355 | action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac))) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 356 | action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid))) |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 357 | action.append(ofp.action.group(group_id)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 358 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 359 | buckets = [ofp.bucket(actions=action)] |
| 360 | |
| 361 | group_id =encode_l3_interface_group_id(id) |
| 362 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 363 | group_id=group_id, |
| 364 | buckets=buckets |
| 365 | ) |
| 366 | ctrl.message_send(request) |
| 367 | return request |
| 368 | |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 369 | def add_l3_ecmp_group(ctrl, id, l3_ucast_groups, send_barrier=False): |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 370 | buckets=[] |
| 371 | for group in l3_ucast_groups: |
| 372 | buckets.append(ofp.bucket(actions=[ofp.action.group(group)])) |
| 373 | |
| 374 | group_id =encode_l3_ecmp_group_id(id) |
| 375 | request = ofp.message.group_add(group_type=ofp.OFPGT_SELECT, |
| 376 | group_id=group_id, |
| 377 | buckets=buckets |
| 378 | ) |
| 379 | ctrl.message_send(request) |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 380 | |
| 381 | if send_barrier: |
| 382 | do_barrier(ctrl) |
| 383 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 384 | return request |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 385 | |
| 386 | def mod_l3_ecmp_group(ctrl, id, l3_ucast_groups): |
| 387 | buckets=[] |
| 388 | for group in l3_ucast_groups: |
| 389 | buckets.append(ofp.bucket(actions=[ofp.action.group(group)])) |
| 390 | |
| 391 | group_id =encode_l3_ecmp_group_id(id) |
| 392 | request = ofp.message.group_modify(group_type=ofp.OFPGT_SELECT, |
| 393 | group_id=group_id, |
| 394 | buckets=buckets |
| 395 | ) |
| 396 | ctrl.message_send(request) |
| 397 | return request |
| 398 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 399 | def add_l3_mcast_group(ctrl, vid, mcast_group_id, groups_on_buckets): |
| 400 | buckets=[] |
| 401 | for group in groups_on_buckets: |
| 402 | buckets.append(ofp.bucket(actions=[ofp.action.group(group)])) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 403 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 404 | group_id =encode_l3_mcast_group_id(vid, mcast_group_id) |
| 405 | request = ofp.message.group_add(group_type=ofp.OFPGT_ALL, |
| 406 | group_id=group_id, |
| 407 | buckets=buckets |
| 408 | ) |
| 409 | ctrl.message_send(request) |
| 410 | return request |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 411 | |
| 412 | def add_l2_overlay_flood_over_unicast_tunnel_group(ctrl, tunnel_id, ports, index): |
| 413 | buckets=[] |
| 414 | for port in ports: |
| 415 | buckets.append(ofp.bucket(actions=[ofp.action.output(port)])) |
| 416 | |
| 417 | group_id=encode_l2_overlay_group_id(tunnel_id, 0, index) |
| 418 | request = ofp.message.group_add(group_type=ofp.OFPGT_ALL, |
| 419 | group_id=group_id, |
| 420 | buckets=buckets |
| 421 | ) |
| 422 | ctrl.message_send(request) |
| 423 | return request |
| 424 | |
| 425 | def add_l2_overlay_flood_over_mcast_tunnel_group(ctrl, tunnel_id, ports, index): |
| 426 | buckets=[] |
| 427 | for port in ports: |
| 428 | buckets.append(ofp.bucket(actions=[ofp.action.output(port)])) |
| 429 | |
| 430 | group_id=encode_l2_overlay_group_id(tunnel_id, 1, index) |
| 431 | request = ofp.message.group_add(group_type=ofp.OFPGT_ALL, |
| 432 | group_id=group_id, |
| 433 | buckets=buckets |
| 434 | ) |
| 435 | ctrl.message_send(request) |
| 436 | return request |
| 437 | |
| 438 | def add_l2_overlay_mcast_over_unicast_tunnel_group(ctrl, tunnel_id, ports, index): |
| 439 | buckets=[] |
| 440 | for port in ports: |
| 441 | buckets.append(ofp.bucket(actions=[ofp.action.output(port)])) |
| 442 | |
| 443 | group_id=encode_l2_overlay_group_id(tunnel_id, 2, index) |
| 444 | request = ofp.message.group_add(group_type=ofp.OFPGT_ALL, |
| 445 | group_id=group_id, |
| 446 | buckets=buckets |
| 447 | ) |
| 448 | ctrl.message_send(request) |
| 449 | return request |
| 450 | |
| 451 | def add_l2_overlay_mcast_over_mcast_tunnel_group(ctrl, tunnel_id, ports, index): |
| 452 | buckets=[] |
| 453 | for port in ports: |
| 454 | buckets.append(ofp.bucket(actions=[ofp.action.output(port)])) |
| 455 | |
| 456 | group_id=encode_l2_overlay_group_id(tunnel_id, 3, index) |
| 457 | request = ofp.message.group_add(group_type=ofp.OFPGT_ALL, |
| 458 | group_id=group_id, |
| 459 | buckets=buckets |
| 460 | ) |
| 461 | ctrl.message_send(request) |
| 462 | return request |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 463 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 464 | def add_port_table_flow(ctrl, is_overlay=True): |
| 465 | match = ofp.match() |
| 466 | |
| 467 | if is_overlay == True: |
| 468 | match.oxm_list.append(ofp.oxm.in_port(0x10000)) |
macauley | dbff327 | 2015-07-30 14:07:16 +0800 | [diff] [blame] | 469 | NEXT_TABLE=50 |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 470 | else: |
| 471 | match.oxm_list.append(ofp.oxm.in_port(0)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 472 | NEXT_TABLE=10 |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 473 | |
| 474 | request = ofp.message.flow_add( |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 475 | table_id=0, |
| 476 | cookie=42, |
| 477 | match=match, |
| 478 | instructions=[ |
| 479 | ofp.instruction.goto_table(NEXT_TABLE) |
| 480 | ], |
| 481 | priority=0) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 482 | logging.info("Add port table, match port %lx" % 0x10000) |
| 483 | ctrl.message_send(request) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 484 | |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 485 | def pop_vlan_flow(ctrl, ports, vlan_id=1): |
| 486 | # table 10: vlan |
| 487 | # goto to table 20 |
| 488 | msgs=[] |
| 489 | for of_port in ports: |
| 490 | match = ofp.match() |
| 491 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 492 | match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlan_id)) |
| 493 | request = ofp.message.flow_add( |
| 494 | table_id=10, |
| 495 | cookie=42, |
| 496 | match=match, |
| 497 | instructions=[ |
| 498 | ofp.instruction.apply_actions( |
| 499 | actions=[ |
| 500 | ofp.action.pop_vlan() |
| 501 | ] |
| 502 | ), |
| 503 | ofp.instruction.goto_table(20) |
| 504 | ], |
| 505 | priority=0) |
| 506 | logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port)) |
| 507 | ctrl.message_send(request) |
| 508 | |
| 509 | |
| 510 | return msgs |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 511 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 512 | def add_vlan_table_flow(ctrl, ports, vlan_id=1, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False): |
| 513 | # table 10: vlan |
| 514 | # goto to table 20 |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 515 | msgs=[] |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 516 | for of_port in ports: |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 517 | if (flag == VLAN_TABLE_FLAG_ONLY_TAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH) or (flag == 4): |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 518 | match = ofp.match() |
| 519 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 520 | match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlan_id)) |
| 521 | request = ofp.message.flow_add( |
| 522 | table_id=10, |
| 523 | cookie=42, |
| 524 | match=match, |
| 525 | instructions=[ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 526 | ofp.instruction.apply_actions( |
| 527 | actions=[ |
| 528 | ofp.action.pop_vlan() |
| 529 | ] |
| 530 | ), |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 531 | ofp.instruction.goto_table(20) |
| 532 | ], |
| 533 | priority=0) |
| 534 | logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port)) |
| 535 | ctrl.message_send(request) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 536 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 537 | if (flag == VLAN_TABLE_FLAG_ONLY_UNTAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH): |
| 538 | match = ofp.match() |
| 539 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 540 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0, 0x1fff)) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 541 | request = ofp.message.flow_add( |
| 542 | table_id=10, |
| 543 | cookie=42, |
| 544 | match=match, |
| 545 | instructions=[ |
| 546 | ofp.instruction.apply_actions( |
| 547 | actions=[ |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 548 | ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlan_id)) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 549 | ] |
| 550 | ), |
| 551 | ofp.instruction.goto_table(20) |
| 552 | ], |
| 553 | priority=0) |
| 554 | logging.info("Add vlan %d untagged packets on port %d and go to table 20" % (vlan_id, of_port)) |
| 555 | ctrl.message_send(request) |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 556 | msgs.append(request) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 557 | |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 558 | if (flag == 4) : |
| 559 | match = ofp.match() |
| 560 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 561 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000, 0x1fff)) |
| 562 | request = ofp.message.flow_add( |
| 563 | table_id=10, |
| 564 | cookie=42, |
| 565 | match=match, |
| 566 | instructions=[ |
| 567 | ofp.instruction.apply_actions( |
| 568 | actions=[ |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 569 | ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlan_id)) |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 570 | ] |
| 571 | ), |
| 572 | ofp.instruction.goto_table(20) |
| 573 | ], |
| 574 | priority=0) |
| 575 | logging.info("Add vlan %d untagged packets on port %d and go to table 20" % (vlan_id, of_port)) |
| 576 | ctrl.message_send(request) |
| 577 | msgs.append(request) |
| 578 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 579 | if send_barrier: |
| 580 | do_barrier(ctrl) |
| 581 | |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 582 | return msgs |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 583 | |
macauley_cheng | 6e6a612 | 2015-11-16 14:19:18 +0800 | [diff] [blame] | 584 | def del_vlan_table_flow(ctrl, ports, vlan_id=1, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False): |
| 585 | # table 10: vlan |
| 586 | # goto to table 20 |
| 587 | msgs=[] |
| 588 | for of_port in ports: |
| 589 | if (flag == VLAN_TABLE_FLAG_ONLY_TAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH): |
| 590 | match = ofp.match() |
| 591 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 592 | match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlan_id)) |
| 593 | request = ofp.message.flow_delete( |
| 594 | table_id=10, |
| 595 | cookie=42, |
| 596 | match=match, |
| 597 | priority=0) |
| 598 | logging.info("Del vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port)) |
| 599 | ctrl.message_send(request) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 600 | |
macauley_cheng | 6e6a612 | 2015-11-16 14:19:18 +0800 | [diff] [blame] | 601 | if (flag == VLAN_TABLE_FLAG_ONLY_UNTAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH): |
| 602 | match = ofp.match() |
| 603 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 604 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0, 0xfff)) |
| 605 | request = ofp.message.flow_delete( |
| 606 | table_id=10, |
| 607 | cookie=42, |
| 608 | match=match, |
| 609 | priority=0) |
| 610 | logging.info("Del vlan %d untagged packets on port %d and go to table 20" % (vlan_id, of_port)) |
| 611 | ctrl.message_send(request) |
| 612 | msgs.append(request) |
| 613 | |
| 614 | if send_barrier: |
| 615 | do_barrier(ctrl) |
| 616 | |
| 617 | return msgs |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 618 | |
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 619 | def add_vlan_table_flow_pvid(ctrl, in_port, match_vid=None, pvid=1, send_barrier=False): |
| 620 | """it will tag pack as untagged packet wether it has tagg or not""" |
| 621 | match = ofp.match() |
| 622 | match.oxm_list.append(ofp.oxm.in_port(in_port)) |
| 623 | actions=[] |
| 624 | if match_vid == None: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 625 | match.oxm_list.append(ofp.oxm.vlan_vid(0)) |
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 626 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+pvid))) |
| 627 | goto_table=20 |
| 628 | else: |
| 629 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+match_vid, 0x1fff)) |
| 630 | actions.append(ofp.action.push_vlan(0x8100)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 631 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+pvid))) |
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 632 | goto_table=20 |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 633 | |
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 634 | request = ofp.message.flow_add( |
| 635 | table_id=10, |
| 636 | cookie=42, |
| 637 | match=match, |
| 638 | instructions=[ |
| 639 | ofp.instruction.apply_actions(actions=actions) |
| 640 | ,ofp.instruction.goto_table(goto_table) |
| 641 | ], |
| 642 | priority=0) |
| 643 | logging.info("Add PVID %d on port %d and go to table %ld" %( pvid, in_port, goto_table)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 644 | ctrl.message_send(request) |
| 645 | |
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 646 | if send_barrier: |
| 647 | do_barrier(ctrl) |
| 648 | |
| 649 | def add_vlan_table_flow_allow_all_vlan(ctrl, in_port, send_barrier=False): |
| 650 | """it st flow allow all vlan tag on this port""" |
| 651 | match = ofp.match() |
| 652 | match.oxm_list.append(ofp.oxm.in_port(in_port)) |
| 653 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000, 0x1000)) |
| 654 | request = ofp.message.flow_add( |
| 655 | table_id=10, |
| 656 | cookie=42, |
| 657 | match=match, |
| 658 | instructions=[ |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 659 | ofp.instruction.goto_table(20) |
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 660 | ], |
| 661 | priority=0) |
| 662 | logging.info("Add allow all vlan on port %d " %(in_port)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 663 | ctrl.message_send(request) |
macauley_cheng | 6b31161 | 2015-09-04 11:32:27 +0800 | [diff] [blame] | 664 | |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 665 | def add_one_vlan_table_flow_translation(ctrl, of_port, vlan_id=1, new_vlan_id=-1, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False): |
| 666 | # Install a flow for VLAN translation |
| 667 | # in VLAN table. |
| 668 | # table 10: vlan |
| 669 | # goto to table 20 |
| 670 | if (flag == VLAN_TABLE_FLAG_ONLY_TAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH) or (flag == 4): |
| 671 | match = ofp.match() |
| 672 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 673 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+vlan_id,0x1fff)) |
| 674 | |
| 675 | actions=[] |
| 676 | if vrf!=0: |
| 677 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))) |
| 678 | if new_vlan_id != -1: |
| 679 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+new_vlan_id))) |
| 680 | |
| 681 | request = ofp.message.flow_add( |
| 682 | table_id=10, |
| 683 | cookie=42, |
| 684 | match=match, |
| 685 | instructions=[ |
| 686 | ofp.instruction.apply_actions( |
| 687 | actions=actions |
| 688 | ), |
| 689 | ofp.instruction.goto_table(20) |
| 690 | ], |
| 691 | priority=0) |
| 692 | logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port)) |
| 693 | ctrl.message_send(request) |
| 694 | |
Pier | e130876 | 2016-09-12 15:29:56 -0700 | [diff] [blame] | 695 | def add_one_vlan_table_flow(ctrl, of_port, out_vlan_id=1, vlan_id=1, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False): |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 696 | # table 10: vlan |
| 697 | # goto to table 20 |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 698 | if (flag == VLAN_TABLE_FLAG_ONLY_TAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH) or (flag == 4): |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 699 | match = ofp.match() |
| 700 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 701 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+vlan_id,0x1fff)) |
macauley | 7f89d96 | 2015-08-06 18:13:48 +0800 | [diff] [blame] | 702 | |
| 703 | actions=[] |
| 704 | if vrf!=0: |
Pier | 23784aa | 2016-09-19 20:08:21 -0700 | [diff] [blame] | 705 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 706 | |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 707 | #actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(value=vlan_id))) |
macauley | 7f89d96 | 2015-08-06 18:13:48 +0800 | [diff] [blame] | 708 | |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 709 | request = ofp.message.flow_add( |
| 710 | table_id=10, |
| 711 | cookie=42, |
| 712 | match=match, |
| 713 | instructions=[ |
macauley | 53d90fe | 2015-08-04 17:34:22 +0800 | [diff] [blame] | 714 | ofp.instruction.apply_actions( |
macauley | 7f89d96 | 2015-08-06 18:13:48 +0800 | [diff] [blame] | 715 | actions=actions |
macauley | 53d90fe | 2015-08-04 17:34:22 +0800 | [diff] [blame] | 716 | ), |
| 717 | ofp.instruction.goto_table(20) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 718 | ], |
| 719 | priority=0) |
| 720 | logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port)) |
| 721 | ctrl.message_send(request) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 722 | |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 723 | if (flag == VLAN_TABLE_FLAG_ONLY_UNTAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH): |
| 724 | match = ofp.match() |
| 725 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 726 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0, 0x1fff)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 727 | |
macauley | 7f89d96 | 2015-08-06 18:13:48 +0800 | [diff] [blame] | 728 | actions=[] |
| 729 | if vrf!=0: |
| 730 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 731 | |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 732 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlan_id))) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 733 | |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 734 | request = ofp.message.flow_add( |
| 735 | table_id=10, |
| 736 | cookie=42, |
| 737 | match=match, |
| 738 | instructions=[ |
| 739 | ofp.instruction.apply_actions( |
macauley | 7f89d96 | 2015-08-06 18:13:48 +0800 | [diff] [blame] | 740 | actions=actions |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 741 | ), |
| 742 | ofp.instruction.goto_table(20) |
| 743 | ], |
| 744 | priority=0) |
| 745 | logging.info("Add vlan %d untagged packets on port %d and go to table 20" % (vlan_id, of_port)) |
| 746 | ctrl.message_send(request) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 747 | |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 748 | if (flag == 4) : |
| 749 | match = ofp.match() |
| 750 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 751 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000,0x1fff)) |
| 752 | |
| 753 | actions=[] |
| 754 | if vrf!=0: |
| 755 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))) |
| 756 | |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 757 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlan_id))) |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 758 | |
| 759 | request = ofp.message.flow_add( |
| 760 | table_id=10, |
| 761 | cookie=42, |
| 762 | match=match, |
| 763 | instructions=[ |
| 764 | ofp.instruction.apply_actions( |
| 765 | actions=actions |
| 766 | ), |
| 767 | ofp.instruction.goto_table(20) |
| 768 | ], |
| 769 | priority=0) |
| 770 | logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port)) |
| 771 | ctrl.message_send(request) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 772 | |
Pier | e130876 | 2016-09-12 15:29:56 -0700 | [diff] [blame] | 773 | if (flag == VLAN_TABLE_FLAG_ONLY_STACKED): |
| 774 | # This flag is meant to managed stacked vlan packtes |
| 775 | # Matches on outer VLAN_ID, set OVID with outer VLAN. |
| 776 | # Finally expose inner VLAN_ID with a pop action and |
| 777 | # goto VLAN_1_FLOW_TABLE |
| 778 | match = ofp.match() |
| 779 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 780 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+vlan_id,0x1fff)) |
| 781 | |
| 782 | actions=[] |
| 783 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_OVID, value=0x1000+vlan_id))) |
| 784 | actions.append(ofp.action.pop_vlan()) |
| 785 | |
| 786 | request = ofp.message.flow_add( |
| 787 | table_id=10, |
| 788 | cookie=42, |
| 789 | match=match, |
| 790 | instructions=[ |
| 791 | ofp.instruction.apply_actions( |
| 792 | actions=actions |
| 793 | ), |
| 794 | ofp.instruction.goto_table(VLAN_1_FLOW_TABLE) |
| 795 | ], |
| 796 | priority=0) |
| 797 | logging.info("Add vlan %d tagged packets on port %d and go to table %d" %( vlan_id, of_port, VLAN_1_FLOW_TABLE)) |
| 798 | ctrl.message_send(request) |
| 799 | |
| 800 | if (flag == VLAN_TABLE_FLAG_PRIORITY) : |
| 801 | match = ofp.match() |
| 802 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 803 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000, 0x1fff)) |
| 804 | request = ofp.message.flow_add( |
| 805 | table_id=10, |
| 806 | cookie=42, |
| 807 | match=match, |
| 808 | instructions=[ |
| 809 | ofp.instruction.apply_actions( |
| 810 | actions=[ |
| 811 | ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlan_id)), |
| 812 | ofp.action.push_vlan(0x8100), |
| 813 | ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+out_vlan_id)), |
| 814 | ] |
| 815 | ), |
| 816 | ofp.instruction.goto_table(20) |
| 817 | ], |
| 818 | priority=0) |
| 819 | logging.info("Add vlan %d untagged packets on port %d and go to table 20" % (vlan_id, of_port)) |
| 820 | ctrl.message_send(request) |
| 821 | |
| 822 | if send_barrier: |
| 823 | do_barrier(ctrl) |
| 824 | |
| 825 | return request |
| 826 | |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 827 | def add_one_vlan_table_flow_pw(ctrl, of_port, tunnel_index, new_vlan_id=1, vlan_id=1, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_TAG, send_barrier=False): |
| 828 | # table 10: vlan |
| 829 | # goto to table 13 |
| 830 | if flag == VLAN_TABLE_FLAG_ONLY_TAG: |
| 831 | match = ofp.match() |
| 832 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 833 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+vlan_id, 0x1fff)) |
| 834 | |
| 835 | actions=[] |
| 836 | if vlan_id == -1: |
| 837 | actions.append(ofp.action.pop_vlan()) |
| 838 | if new_vlan_id > 1: |
| 839 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+new_vlan_id))) |
| 840 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_TYPE, value=ofp.oxm.VPWS))) |
| 841 | actions.append(ofp.action.set_field(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE))) |
| 842 | # 0x0000nnnn is for UNI interfaces |
| 843 | actions.append(ofp.action.set_field(ofp.oxm.exp4ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_L2_PORT, value=0x00000000 + of_port))) |
| 844 | |
| 845 | request = ofp.message.flow_add( |
| 846 | table_id=10, |
| 847 | cookie=42, |
| 848 | match=match, |
| 849 | instructions=[ |
| 850 | ofp.instruction.apply_actions( |
| 851 | actions=actions |
| 852 | ), |
| 853 | ofp.instruction.goto_table(MPLS_L2_PORT_FLOW_TABLE) |
| 854 | ], |
| 855 | priority=0) |
| 856 | logging.info("Add vlan %d tagged packets on port %d and go to table %d" % (vlan_id, of_port, MPLS_L2_PORT_FLOW_TABLE)) |
| 857 | ctrl.message_send(request) |
| 858 | |
| 859 | if flag == VLAN_TABLE_FLAG_ONLY_UNTAG: |
| 860 | match = ofp.match() |
| 861 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 862 | match.oxm_list.append(ofp.oxm.vlan_vid(0)) |
| 863 | |
| 864 | actions=[] |
| 865 | if vlan_id > 1: |
| 866 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlan_id))) |
| 867 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_TYPE, value=ofp.oxm.VPWS))) |
| 868 | actions.append(ofp.action.set_field(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE))) |
| 869 | # 0x0000nnnn is for UNI interfaces |
| 870 | actions.append(ofp.action.set_field(ofp.oxm.exp4ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_L2_PORT, value=0x00000000 + of_port))) |
| 871 | |
| 872 | request = ofp.message.flow_add( |
| 873 | table_id=10, |
| 874 | cookie=42, |
| 875 | match=match, |
| 876 | instructions=[ |
| 877 | ofp.instruction.apply_actions( |
| 878 | actions=actions |
| 879 | ), |
| 880 | ofp.instruction.goto_table(MPLS_L2_PORT_FLOW_TABLE) |
| 881 | ], |
| 882 | priority=0) |
| 883 | logging.info("Add vlan %d untagged packets on port %d and go to table %d" % (vlan_id, of_port, MPLS_L2_PORT_FLOW_TABLE)) |
| 884 | ctrl.message_send(request) |
| 885 | |
| 886 | if send_barrier: |
| 887 | do_barrier(ctrl) |
| 888 | |
| 889 | return request |
| 890 | |
Pier | e130876 | 2016-09-12 15:29:56 -0700 | [diff] [blame] | 891 | def add_one_vlan_1_table_flow(ctrl, of_port, new_outer_vlan_id=-1, outer_vlan_id=1, inner_vlan_id=1, flag=VLAN_TABLE_FLAG_ONLY_TAG, send_barrier=False): |
| 892 | # table 11: vlan 1 table |
| 893 | # goto to table 20 |
| 894 | if flag == VLAN_TABLE_FLAG_ONLY_TAG: |
| 895 | match = ofp.match() |
| 896 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 897 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+inner_vlan_id,0x1fff)) |
| 898 | match.oxm_list.append(ofp.oxm.exp2ByteValue(ofp.oxm.OFDPA_EXP_TYPE_OVID, 0x1000+outer_vlan_id)) |
| 899 | |
| 900 | actions=[] |
| 901 | actions.append(ofp.action.push_vlan(0x8100)) |
| 902 | if new_outer_vlan_id != -1: |
| 903 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+new_outer_vlan_id))) |
| 904 | else: |
| 905 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+outer_vlan_id))) |
| 906 | |
| 907 | request = ofp.message.flow_add( |
| 908 | table_id=11, |
| 909 | cookie=42, |
| 910 | match=match, |
| 911 | instructions=[ |
| 912 | ofp.instruction.apply_actions( |
| 913 | actions=actions |
| 914 | ), |
| 915 | ofp.instruction.goto_table(TERMINATION_FLOW_TABLE) |
| 916 | ], |
| 917 | priority=0) |
| 918 | logging.info("Add vlan 1 double tagged %d-%d packets on port %d and go to table %d" %( outer_vlan_id, inner_vlan_id, of_port, TERMINATION_FLOW_TABLE)) |
| 919 | ctrl.message_send(request) |
| 920 | |
| 921 | if flag == VLAN_TABLE_FLAG_ONLY_UNTAG: |
| 922 | match = ofp.match() |
| 923 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 924 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+inner_vlan_id,0x1fff)) |
| 925 | match.oxm_list.append(ofp.oxm.exp2ByteValue(ofp.oxm.OFDPA_EXP_TYPE_OVID, 0x1000+outer_vlan_id)) |
| 926 | |
| 927 | actions=[] |
| 928 | request = ofp.message.flow_add( |
| 929 | table_id=11, |
| 930 | cookie=42, |
| 931 | match=match, |
| 932 | instructions=[ |
| 933 | ofp.instruction.apply_actions( |
| 934 | actions=actions |
| 935 | ), |
| 936 | ofp.instruction.goto_table(TERMINATION_FLOW_TABLE) |
| 937 | ], |
| 938 | priority=0) |
| 939 | logging.info("Add vlan 1 double tagged %d-%d packets on port %d and go to table %d" %( outer_vlan_id, inner_vlan_id, of_port, TERMINATION_FLOW_TABLE)) |
| 940 | ctrl.message_send(request) |
| 941 | |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 942 | if send_barrier: |
| 943 | do_barrier(ctrl) |
| 944 | |
| 945 | return request |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 946 | |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 947 | def add_one_vlan_1_table_flow_pw(ctrl, of_port, tunnel_index, new_outer_vlan_id=-1, outer_vlan_id=1, inner_vlan_id=1, flag=VLAN_TABLE_FLAG_ONLY_TAG, send_barrier=False): |
| 948 | # table 11: vlan 1 table |
| 949 | # goto to table 13 |
| 950 | match = ofp.match() |
| 951 | match.oxm_list.append(ofp.oxm.in_port(of_port)) |
| 952 | match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+inner_vlan_id,0x1fff)) |
| 953 | match.oxm_list.append(ofp.oxm.exp2ByteValue(ofp.oxm.OFDPA_EXP_TYPE_OVID, 0x1000+outer_vlan_id)) |
| 954 | |
| 955 | actions=[] |
| 956 | actions.append(ofp.action.push_vlan(0x8100)) |
| 957 | if new_outer_vlan_id != -1: |
| 958 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+new_outer_vlan_id))) |
| 959 | else: |
| 960 | actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+outer_vlan_id))) |
| 961 | |
| 962 | actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_TYPE, value=ofp.oxm.VPWS))) |
| 963 | actions.append(ofp.action.set_field(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE))) |
| 964 | # 0x0000nnnn is for UNI interfaces |
| 965 | actions.append(ofp.action.set_field(ofp.oxm.exp4ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_L2_PORT, value=0x00000000 + of_port))) |
| 966 | |
| 967 | request = ofp.message.flow_add( |
| 968 | table_id=11, |
| 969 | cookie=42, |
| 970 | match=match, |
| 971 | instructions=[ |
| 972 | ofp.instruction.apply_actions( |
| 973 | actions=actions |
| 974 | ), |
| 975 | ofp.instruction.goto_table(MPLS_L2_PORT_FLOW_TABLE) |
| 976 | ], |
| 977 | priority=0) |
| 978 | logging.info("Add vlan 1 double tagged %d-%d packets on port %d and go to table %d" %( outer_vlan_id, inner_vlan_id, of_port, MPLS_L2_PORT_FLOW_TABLE)) |
| 979 | ctrl.message_send(request) |
| 980 | |
| 981 | if send_barrier: |
| 982 | do_barrier(ctrl) |
| 983 | |
| 984 | return request |
| 985 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 986 | def add_bridge_flow(ctrl, dst_mac, vlanid, group_id, send_barrier=False): |
| 987 | match = ofp.match() |
castroflavio | 2189448 | 2015-12-08 15:29:55 -0500 | [diff] [blame] | 988 | priority=500 |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 989 | if dst_mac!=None: |
castroflavio | 2189448 | 2015-12-08 15:29:55 -0500 | [diff] [blame] | 990 | priority=1000 |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 991 | match.oxm_list.append(ofp.oxm.eth_dst(dst_mac)) |
| 992 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 993 | match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlanid)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 994 | |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 995 | request = ofp.message.flow_add( |
| 996 | table_id=50, |
| 997 | cookie=42, |
| 998 | match=match, |
| 999 | instructions=[ |
| 1000 | ofp.instruction.write_actions( |
| 1001 | actions=[ |
| 1002 | ofp.action.group(group_id)]), |
| 1003 | ofp.instruction.goto_table(60) |
| 1004 | ], |
| 1005 | buffer_id=ofp.OFP_NO_BUFFER, |
castroflavio | 2189448 | 2015-12-08 15:29:55 -0500 | [diff] [blame] | 1006 | priority=priority) |
macauley | 9755723 | 2015-07-16 17:28:07 +0800 | [diff] [blame] | 1007 | |
| 1008 | logging.info("Inserting Brdige flow vlan %d, mac %s", vlanid, dst_mac) |
| 1009 | ctrl.message_send(request) |
| 1010 | |
| 1011 | if send_barrier: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1012 | do_barrier(ctrl) |
macauley | 15909e7 | 2015-07-17 15:58:57 +0800 | [diff] [blame] | 1013 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1014 | return request |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1015 | |
| 1016 | def add_overlay_bridge_flow(ctrl, dst_mac, vnid, group_id, is_group=True, send_barrier=False): |
| 1017 | match = ofp.match() |
| 1018 | if dst_mac!=None: |
| 1019 | match.oxm_list.append(ofp.oxm.eth_dst(dst_mac)) |
| 1020 | |
| 1021 | match.oxm_list.append(ofp.oxm.tunnel_id(vnid)) |
| 1022 | if is_group == True: |
| 1023 | actions=[ofp.action.group(group_id)] |
| 1024 | else: |
| 1025 | actions=[ofp.action.output(group_id)] |
| 1026 | |
| 1027 | request = ofp.message.flow_add( |
| 1028 | table_id=50, |
| 1029 | cookie=42, |
| 1030 | match=match, |
| 1031 | instructions=[ |
| 1032 | ofp.instruction.write_actions( |
| 1033 | actions=actions), |
| 1034 | ofp.instruction.goto_table(60) |
| 1035 | ], |
| 1036 | buffer_id=ofp.OFP_NO_BUFFER, |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1037 | priority=1000) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1038 | |
| 1039 | logging.info("Inserting Brdige flow vnid %d, mac %s", vnid, dst_mac) |
| 1040 | ctrl.message_send(request) |
| 1041 | |
| 1042 | if send_barrier: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1043 | do_barrier(ctrl) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1044 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1045 | return request |
| 1046 | |
macauley_cheng | 6b13366 | 2015-11-09 13:52:39 +0800 | [diff] [blame] | 1047 | def add_termination_flow(ctrl, in_port, eth_type, dst_mac, vlanid, goto_table=None, send_barrier=False): |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1048 | match = ofp.match() |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1049 | match.oxm_list.append(ofp.oxm.eth_type(eth_type)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1050 | if dst_mac[0]&0x01 == 0x01: |
| 1051 | match.oxm_list.append(ofp.oxm.eth_dst_masked(dst_mac, [0xff, 0xff, 0xff, 0x80, 0x00, 0x00])) |
| 1052 | goto_table=40 |
| 1053 | else: |
macauley | 53d90fe | 2015-08-04 17:34:22 +0800 | [diff] [blame] | 1054 | if in_port!=0: |
| 1055 | match.oxm_list.append(ofp.oxm.in_port(in_port)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1056 | match.oxm_list.append(ofp.oxm.eth_dst(dst_mac)) |
| 1057 | match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlanid)) |
macauley_cheng | 6b13366 | 2015-11-09 13:52:39 +0800 | [diff] [blame] | 1058 | if goto_table == None: |
| 1059 | goto_table=30 |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1060 | |
| 1061 | request = ofp.message.flow_add( |
| 1062 | table_id=20, |
| 1063 | cookie=42, |
| 1064 | match=match, |
| 1065 | instructions=[ |
| 1066 | ofp.instruction.goto_table(goto_table) |
| 1067 | ], |
| 1068 | buffer_id=ofp.OFP_NO_BUFFER, |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1069 | priority=1) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1070 | |
| 1071 | logging.info("Inserting termination flow inport %d, eth_type %lx, vlan %d, mac %s", in_port, eth_type, vlanid, dst_mac) |
| 1072 | ctrl.message_send(request) |
| 1073 | |
| 1074 | if send_barrier: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1075 | do_barrier(ctrl) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1076 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1077 | return request |
| 1078 | |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1079 | def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False): |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1080 | match = ofp.match() |
| 1081 | match.oxm_list.append(ofp.oxm.eth_type(eth_type)) |
macauley | 53d90fe | 2015-08-04 17:34:22 +0800 | [diff] [blame] | 1082 | if vrf != 0: |
| 1083 | match.oxm_list.append(ofp.oxm.exp2ByteValue(ofp.oxm.OFDPA_EXP_TYPE_VRF, vrf)) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1084 | |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1085 | match.oxm_list.append(ofp.oxm.ipv4_dst_masked(dst_ip, mask)) |
| 1086 | |
| 1087 | instructions = [] |
| 1088 | instructions.append(ofp.instruction.goto_table(60)) |
| 1089 | if send_ctrl: |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1090 | instructions.append(ofp.instruction.write_actions( |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1091 | actions=[ofp.action.output( port=ofp.OFPP_CONTROLLER, |
| 1092 | max_len=ofp.OFPCML_NO_BUFFER)])) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1093 | else: |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1094 | instructions.append(ofp.instruction.write_actions( |
| 1095 | actions=[ofp.action.group(action_group_id)])) |
macauley | 53d90fe | 2015-08-04 17:34:22 +0800 | [diff] [blame] | 1096 | |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1097 | request = ofp.message.flow_add( |
| 1098 | table_id=30, |
| 1099 | cookie=42, |
| 1100 | match=match, |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1101 | instructions=instructions, |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1102 | buffer_id=ofp.OFP_NO_BUFFER, |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1103 | priority=1) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1104 | |
| 1105 | logging.info("Inserting unicast routing flow eth_type %lx, dip %ld",eth_type, dst_ip) |
| 1106 | ctrl.message_send(request) |
| 1107 | |
| 1108 | if send_barrier: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1109 | do_barrier(ctrl) |
macauley | 0f91a3e | 2015-07-17 18:09:59 +0800 | [diff] [blame] | 1110 | |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1111 | return request |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 1112 | |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 1113 | def add_unicast_v6_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False): |
| 1114 | match = ofp.match() |
| 1115 | match.oxm_list.append(ofp.oxm.eth_type(eth_type)) |
| 1116 | if vrf != 0: |
| 1117 | match.oxm_list.append(ofp.oxm.exp2ByteValue(ofp.oxm.OFDPA_EXP_TYPE_VRF, vrf)) |
| 1118 | |
| 1119 | match.oxm_list.append(ofp.oxm.ipv6_dst_masked(parse_ipv6(dst_ip), parse_ipv6(mask))) |
| 1120 | |
| 1121 | instructions = [] |
| 1122 | instructions.append(ofp.instruction.goto_table(60)) |
| 1123 | if send_ctrl: |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1124 | instructions.append(ofp.instruction.write_actions( |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 1125 | actions=[ofp.action.output( port=ofp.OFPP_CONTROLLER, |
| 1126 | max_len=ofp.OFPCML_NO_BUFFER)])) |
| 1127 | else: |
| 1128 | instructions.append(ofp.instruction.write_actions( |
| 1129 | actions=[ofp.action.group(action_group_id)])) |
| 1130 | |
| 1131 | request = ofp.message.flow_add( |
| 1132 | table_id=30, |
| 1133 | cookie=42, |
| 1134 | match=match, |
| 1135 | instructions=instructions, |
| 1136 | buffer_id=ofp.OFP_NO_BUFFER, |
| 1137 | priority=1) |
| 1138 | |
| 1139 | logging.info("Inserting unicast routing flow eth_type %lx, dip %s",eth_type, dst_ip) |
| 1140 | ctrl.message_send(request) |
| 1141 | |
| 1142 | if send_barrier: |
| 1143 | do_barrier(ctrl) |
| 1144 | |
| 1145 | return request |
| 1146 | |
Flavio Castro | 8ca5254 | 2016-04-11 11:24:49 -0400 | [diff] [blame] | 1147 | def add_mpls_flow(ctrl, action_group_id=0x0, label=100 ,ethertype=0x0800, bos=1, vrf=1, goto_table=27, send_barrier=False): |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1148 | match = ofp.match() |
| 1149 | match.oxm_list.append(ofp.oxm.eth_type(0x8847)) |
| 1150 | match.oxm_list.append(ofp.oxm.mpls_label(label)) |
| 1151 | match.oxm_list.append(ofp.oxm.mpls_bos(bos)) |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1152 | write_actions = [] |
| 1153 | write_actions.append(ofp.action.group(action_group_id)) |
| 1154 | apply_actions = [] |
| 1155 | apply_actions = [ofp.action.dec_mpls_ttl(), |
Flavio Castro | 8ca5254 | 2016-04-11 11:24:49 -0400 | [diff] [blame] | 1156 | ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))] |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1157 | if (goto_table != 29): |
| 1158 | apply_actions.append(ofp.action.set_field( |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1159 | ofp.oxm.exp2ByteValue(exp_type=23, value=32))) |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1160 | apply_actions.append(ofp.action.copy_ttl_in()) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1161 | |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1162 | request = ofp.message.flow_add( |
| 1163 | table_id=24, |
| 1164 | cookie=43, |
| 1165 | match=match, |
| 1166 | instructions=[ |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1167 | ofp.instruction.apply_actions(actions=apply_actions), |
| 1168 | ofp.instruction.write_actions(actions=write_actions), |
Flavio Castro | 8ca5254 | 2016-04-11 11:24:49 -0400 | [diff] [blame] | 1169 | ofp.instruction.goto_table(goto_table) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1170 | ], |
| 1171 | buffer_id=ofp.OFP_NO_BUFFER, |
| 1172 | priority=1) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1173 | logging.info("Inserting MPLS flow , label %ld", label) |
| 1174 | ctrl.message_send(request) |
| 1175 | |
| 1176 | if send_barrier: |
| 1177 | do_barrier(ctrl) |
| 1178 | |
| 1179 | return request |
| 1180 | |
Pier | f6f2816 | 2016-09-22 16:30:52 -0700 | [diff] [blame] | 1181 | def add_mpls_flow_pw(ctrl, action_group_id, label, ethertype, bos, tunnel_index, goto_table=MPLS_TYPE_FLOW_TABLE, popMPLS=True, popL2=False, of_port=0, send_barrier=False): |
Pier | b5da4c9 | 2016-09-21 11:23:35 -0700 | [diff] [blame] | 1182 | match = ofp.match() |
| 1183 | match.oxm_list.append(ofp.oxm.eth_type(0x8847)) |
| 1184 | match.oxm_list.append(ofp.oxm.mpls_label(label)) |
| 1185 | match.oxm_list.append(ofp.oxm.mpls_bos(bos)) |
| 1186 | |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1187 | apply_actions = [] |
| 1188 | write_actions = [] |
| 1189 | apply_actions.append(ofp.action.dec_mpls_ttl()) |
Pier | f6f2816 | 2016-09-22 16:30:52 -0700 | [diff] [blame] | 1190 | if popMPLS == True: |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1191 | apply_actions.append(ofp.action.copy_ttl_in()) |
| 1192 | apply_actions.append(ofp.action.pop_mpls(ethertype)) |
Pier | f6f2816 | 2016-09-22 16:30:52 -0700 | [diff] [blame] | 1193 | if bos==1 and popL2 == True: |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1194 | apply_actions.append(ofp.action.ofdpa_pop_l2_header()) |
| 1195 | apply_actions.append(ofp.action.ofdpa_pop_cw()) |
| 1196 | apply_actions.append(ofp.action.set_field(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE))) |
Pier | f6f2816 | 2016-09-22 16:30:52 -0700 | [diff] [blame] | 1197 | # 0x0002nnnn is for UNI interfaces |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1198 | apply_actions.append(ofp.action.set_field(ofp.oxm.exp4ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_L2_PORT, value=0x00020000 + of_port))) |
| 1199 | apply_actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_TYPE, value=ofp.oxm.VPWS))) |
| 1200 | write_actions.append(ofp.action.group(action_group_id)) |
Pier | b5da4c9 | 2016-09-21 11:23:35 -0700 | [diff] [blame] | 1201 | |
| 1202 | request = ofp.message.flow_add( |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1203 | table_id=24, |
| 1204 | cookie=43, |
| 1205 | match=match, |
| 1206 | instructions=[ |
| 1207 | ofp.instruction.apply_actions(actions=apply_actions), |
| 1208 | ofp.instruction.write_actions(actions=write_actions), |
| 1209 | ofp.instruction.goto_table(goto_table) |
| 1210 | ], |
| 1211 | buffer_id=ofp.OFP_NO_BUFFER, |
| 1212 | priority=1) |
Pier | b5da4c9 | 2016-09-21 11:23:35 -0700 | [diff] [blame] | 1213 | logging.info("Inserting MPLS flow , label %ld", label) |
| 1214 | ctrl.message_send(request) |
| 1215 | |
| 1216 | if send_barrier: |
| 1217 | do_barrier(ctrl) |
| 1218 | |
| 1219 | return request |
| 1220 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1221 | def add_mcast4_routing_flow(ctrl, vlan_id, src_ip, src_ip_mask, dst_ip, action_group_id, send_barrier=False): |
| 1222 | match = ofp.match() |
| 1223 | match.oxm_list.append(ofp.oxm.eth_type(0x0800)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1224 | match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1225 | if src_ip_mask!=0: |
| 1226 | match.oxm_list.append(ofp.oxm.ipv4_src_masked(src_ip, src_ip_mask)) |
| 1227 | else: |
| 1228 | match.oxm_list.append(ofp.oxm.ipv4_src(src_ip)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1229 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1230 | match.oxm_list.append(ofp.oxm.ipv4_dst(dst_ip)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1231 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1232 | request = ofp.message.flow_add( |
| 1233 | table_id=40, |
| 1234 | cookie=42, |
| 1235 | match=match, |
| 1236 | instructions=[ |
| 1237 | ofp.instruction.write_actions( |
| 1238 | actions=[ofp.action.group(action_group_id)]), |
| 1239 | ofp.instruction.goto_table(60) |
| 1240 | ], |
| 1241 | buffer_id=ofp.OFP_NO_BUFFER, |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1242 | priority=1) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1243 | |
| 1244 | logging.info("Inserting mcast routing flow eth_type %lx, dip %lx, sip %lx, sip_mask %lx",0x0800, dst_ip, src_ip, src_ip_mask) |
| 1245 | ctrl.message_send(request) |
| 1246 | |
| 1247 | if send_barrier: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1248 | do_barrier(ctrl) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1249 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1250 | return request |
macauley_cheng | 6b13366 | 2015-11-09 13:52:39 +0800 | [diff] [blame] | 1251 | |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 1252 | def add_acl_rule(ctrl, eth_type=None, ip_proto=None, send_barrier=False): |
| 1253 | match = ofp.match() |
| 1254 | if eth_type != None: |
| 1255 | match.oxm_list.append(ofp.oxm.eth_type(eth_type)) |
| 1256 | if ip_proto != None: |
| 1257 | match.oxm_list.append(ofp.oxm.ip_proto(ip_proto)) |
| 1258 | |
| 1259 | request = ofp.message.flow_add( |
| 1260 | table_id=60, |
| 1261 | cookie=42, |
| 1262 | match=match, |
| 1263 | instructions=[ |
| 1264 | ofp.instruction.apply_actions( |
| 1265 | actions=[ofp.action.output(port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER)] |
| 1266 | ), |
| 1267 | ], |
| 1268 | buffer_id=ofp.OFP_NO_BUFFER, |
| 1269 | priority=1 |
| 1270 | ) |
| 1271 | |
| 1272 | logging.info("Inserting ACL flow eth_type %lx, ip_proto %ld", eth_type, ip_proto) |
| 1273 | ctrl.message_send(request) |
| 1274 | |
| 1275 | if send_barrier: |
| 1276 | do_barrier(ctrl) |
| 1277 | |
| 1278 | return request |
| 1279 | |
macauley_cheng | 6b13366 | 2015-11-09 13:52:39 +0800 | [diff] [blame] | 1280 | #dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x71000001 goto:60 |
macauley_cheng | effc20a | 2015-11-09 16:14:56 +0800 | [diff] [blame] | 1281 | def add_dnat_flow(ctrl, eth_type, ip_dst, ip_proto, tcp_dst, set_ip_dst, set_tcp_dst, action_group_id): |
macauley_cheng | 6b13366 | 2015-11-09 13:52:39 +0800 | [diff] [blame] | 1282 | match = ofp.match() |
| 1283 | match.oxm_list.append(ofp.oxm.eth_type(eth_type)) |
| 1284 | match.oxm_list.append(ofp.oxm.ipv4_dst(ip_dst)) |
| 1285 | match.oxm_list.append(ofp.oxm.ip_proto(ip_proto)) |
| 1286 | match.oxm_list.append(ofp.oxm.tcp_dst(tcp_dst)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1287 | |
macauley_cheng | 6b13366 | 2015-11-09 13:52:39 +0800 | [diff] [blame] | 1288 | request = ofp.message.flow_add( |
| 1289 | table_id=28, |
| 1290 | cookie=42, |
| 1291 | match=match, |
| 1292 | instructions=[ |
| 1293 | ofp.instruction.write_actions( |
| 1294 | actions=[ofp.action.set_field(ofp.oxm.ipv4_dst(set_ip_dst)), |
| 1295 | ofp.action.set_field(ofp.oxm.tcp_dst(set_tcp_dst)), |
| 1296 | ofp.action.group(action_group_id)]), |
| 1297 | ofp.instruction.goto_table(60) |
| 1298 | ], |
| 1299 | buffer_id=ofp.OFP_NO_BUFFER, |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1300 | priority=1) |
macauley_cheng | 6b13366 | 2015-11-09 13:52:39 +0800 | [diff] [blame] | 1301 | logging.info("Inserting DNAT flow eth_type %lx, dip %lx, ip_proto %ld, tcp_dst %ld, SetFeild: Dip %lx, tcp_dst %ld, action_gorup=%lx",eth_type, ip_dst, ip_proto, tcp_dst, set_ip_dst, set_tcp_dst, action_group_id) |
| 1302 | ctrl.message_send(request) |
| 1303 | return request |
macauley_cheng | effc20a | 2015-11-09 16:14:56 +0800 | [diff] [blame] | 1304 | |
| 1305 | #dpctl tcp:192.168.1.1:6633 flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30 |
| 1306 | def add_snat_flow(ctrl, eth_type, ip_src, ip_proto, tcp_src, set_ip_src, set_tcp_src): |
| 1307 | match = ofp.match() |
| 1308 | match.oxm_list.append(ofp.oxm.eth_type(eth_type)) |
| 1309 | match.oxm_list.append(ofp.oxm.ipv4_src(ip_src)) |
| 1310 | match.oxm_list.append(ofp.oxm.ip_proto(ip_proto)) |
| 1311 | match.oxm_list.append(ofp.oxm.tcp_src(tcp_src)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1312 | |
macauley_cheng | effc20a | 2015-11-09 16:14:56 +0800 | [diff] [blame] | 1313 | request = ofp.message.flow_add( |
| 1314 | table_id=29, |
| 1315 | cookie=42, |
| 1316 | match=match, |
| 1317 | instructions=[ |
| 1318 | ofp.instruction.write_actions( |
| 1319 | actions=[ofp.action.set_field(ofp.oxm.ipv4_src(set_ip_src)), |
| 1320 | ofp.action.set_field(ofp.oxm.tcp_src(set_tcp_src))]), |
| 1321 | ofp.instruction.goto_table(30) |
| 1322 | ], |
| 1323 | buffer_id=ofp.OFP_NO_BUFFER, |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1324 | priority=1) |
macauley_cheng | effc20a | 2015-11-09 16:14:56 +0800 | [diff] [blame] | 1325 | logging.info("Inserting DNAT flow eth_type %lx, sip %lx, ip_proto %ld, tcp_src %ld, SetFeild: sip %lx, tcp_src %ld",eth_type, ip_src, ip_proto, tcp_src, set_ip_src, set_tcp_src) |
| 1326 | ctrl.message_send(request) |
| 1327 | return request |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1328 | |
| 1329 | def get_vtap_lport_config_xml(dp_id, lport, phy_port, vlan, vnid, operation='merge'): |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1330 | """ |
| 1331 | Command Example: |
| 1332 | of-agent vtap 10001 ethernet 1/1 vid 1 |
| 1333 | of-agent vtp 10001 vni 10 |
| 1334 | """ |
| 1335 | if vlan != 0: |
| 1336 | config_vtap_xml=""" |
| 1337 | <config> |
| 1338 | <capable-switch xmlns="urn:onf:of111:config:yang" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> |
| 1339 | <id>capable-switch-1</id> |
| 1340 | <resources> |
| 1341 | <port xc:operation="OPERATION"> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1342 | <resource-id >LPORT</resource-id> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1343 | <features> |
| 1344 | <current> |
| 1345 | <rate>10Gb</rate> |
| 1346 | <medium>fiber</medium> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1347 | <pause>symmetric</pause> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1348 | </current> |
| 1349 | <advertised> |
| 1350 | <rate>10Gb</rate> |
| 1351 | <rate>100Gb</rate> |
| 1352 | <medium>fiber</medium> |
| 1353 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1354 | </advertised> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1355 | <supported> |
| 1356 | <rate>10Gb</rate> |
| 1357 | <rate>100Gb</rate> |
| 1358 | <medium>fiber</medium> |
| 1359 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1360 | </supported> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1361 | <advertised-peer> |
| 1362 | <rate>10Gb</rate> |
| 1363 | <rate>100Gb</rate> |
| 1364 | <medium>fiber</medium> |
| 1365 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1366 | </advertised-peer> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1367 | </features> |
| 1368 | <ofdpa10:vtap xmlns:ofdpa10="urn:bcm:ofdpa10:accton01" xc:operation="OPERATION"> |
| 1369 | <ofdpa10:phy-port>PHY_PORT</ofdpa10:phy-port> |
| 1370 | <ofdpa10:vid>VLAN_ID</ofdpa10:vid> |
| 1371 | <ofdpa10:vni>VNID</ofdpa10:vni> |
| 1372 | </ofdpa10:vtap> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1373 | </port> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1374 | </resources> |
| 1375 | <logical-switches> |
| 1376 | <switch> |
| 1377 | <id>DATAPATH_ID</id> |
| 1378 | <datapath-id>DATAPATH_ID</datapath-id> |
| 1379 | <resources> |
| 1380 | <port xc:operation="OPERATION">LPORT</port> |
| 1381 | </resources> |
| 1382 | </switch> |
| 1383 | </logical-switches> |
| 1384 | </capable-switch> |
| 1385 | </config> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1386 | """ |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1387 | else: |
| 1388 | config_vtap_xml=""" |
| 1389 | <config> |
| 1390 | <capable-switch xmlns="urn:onf:of111:config:yang" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> |
| 1391 | <id>capable-switch-1</id> |
| 1392 | <resources> |
| 1393 | <port xc:operation="OPERATION"> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1394 | <resource-id >LPORT</resource-id> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1395 | <features> |
| 1396 | <current> |
| 1397 | <rate>10Gb</rate> |
| 1398 | <medium>fiber</medium> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1399 | <pause>symmetric</pause> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1400 | </current> |
| 1401 | <advertised> |
| 1402 | <rate>10Gb</rate> |
| 1403 | <rate>100Gb</rate> |
| 1404 | <medium>fiber</medium> |
| 1405 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1406 | </advertised> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1407 | <supported> |
| 1408 | <rate>10Gb</rate> |
| 1409 | <rate>100Gb</rate> |
| 1410 | <medium>fiber</medium> |
| 1411 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1412 | </supported> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1413 | <advertised-peer> |
| 1414 | <rate>10Gb</rate> |
| 1415 | <rate>100Gb</rate> |
| 1416 | <medium>fiber</medium> |
| 1417 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1418 | </advertised-peer> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1419 | </features> |
| 1420 | <ofdpa10:vtap xmlns:ofdpa10="urn:bcm:ofdpa10:accton01" xc:operation="OPERATION"> |
| 1421 | <ofdpa10:phy-port>PHY_PORT</ofdpa10:phy-port> |
| 1422 | <ofdpa10:vni>VNID</ofdpa10:vni> |
| 1423 | </ofdpa10:vtap> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1424 | </port> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1425 | </resources> |
| 1426 | <logical-switches> |
| 1427 | <switch> |
| 1428 | <id>DATAPATH_ID</id> |
| 1429 | <datapath-id>DATAPATH_ID</datapath-id> |
| 1430 | <resources> |
| 1431 | <port xc:operation="OPERATION">LPORT</port> |
| 1432 | </resources> |
| 1433 | </switch> |
| 1434 | </logical-switches> |
| 1435 | </capable-switch> |
| 1436 | </config> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1437 | """ |
| 1438 | str_datapath_id_f= "{:016x}".format(dp_id) |
| 1439 | str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)]) |
| 1440 | config_vtap_xml=config_vtap_xml.replace("DATAPATH_ID", str_datapath_id) |
| 1441 | config_vtap_xml=config_vtap_xml.replace("LPORT", str(int(lport))) |
| 1442 | config_vtap_xml=config_vtap_xml.replace("PHY_PORT", str(phy_port)) |
| 1443 | config_vtap_xml=config_vtap_xml.replace("VLAN_ID", str(vlan)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1444 | config_vtap_xml=config_vtap_xml.replace("VNID", str(vnid)) |
| 1445 | config_vtap_xml=config_vtap_xml.replace("OPERATION", str(operation)) |
| 1446 | return config_vtap_xml |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1447 | |
| 1448 | def get_vtep_lport_config_xml(dp_id, lport, src_ip, dst_ip, next_hop_id, vnid, udp_src_port=6633, ttl=25, operation='merge'): |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1449 | """ |
| 1450 | Command Example: |
| 1451 | of-agent vtep 10002 source user-input-src-ip destination user-input-dst-ip udp-source-port 6633 nexthop 2 ttl 25 |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1452 | of-agent vtp 10001 vni 10 |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1453 | """ |
| 1454 | |
| 1455 | config_vtep_xml=""" |
| 1456 | <config> |
| 1457 | <capable-switch xmlns="urn:onf:of111:config:yang" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> |
| 1458 | <id>capable-switch-1</id> |
| 1459 | <resources> |
| 1460 | <port xc:operation="OPERATION"> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1461 | <resource-id>LPORT</resource-id> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1462 | <features> |
| 1463 | <current> |
| 1464 | <rate>10Gb</rate> |
| 1465 | <medium>fiber</medium> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1466 | <pause>symmetric</pause> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1467 | </current> |
| 1468 | <advertised> |
| 1469 | <rate>10Gb</rate> |
| 1470 | <rate>100Gb</rate> |
| 1471 | <medium>fiber</medium> |
| 1472 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1473 | </advertised> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1474 | <supported> |
| 1475 | <rate>10Gb</rate> |
| 1476 | <rate>100Gb</rate> |
| 1477 | <medium>fiber</medium> |
| 1478 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1479 | </supported> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1480 | <advertised-peer> |
| 1481 | <rate>10Gb</rate> |
| 1482 | <rate>100Gb</rate> |
| 1483 | <medium>fiber</medium> |
| 1484 | <pause>symmetric</pause> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1485 | </advertised-peer> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1486 | </features> |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1487 | <ofdpa10:vtep xmlns:ofdpa10="urn:bcm:ofdpa10:accton01"> |
| 1488 | <ofdpa10:src-ip>SRC_IP</ofdpa10:src-ip> |
| 1489 | <ofdpa10:dest-ip>DST_IP</ofdpa10:dest-ip> |
| 1490 | <ofdpa10:udp-src-port>UDP_SRC_PORT</ofdpa10:udp-src-port> |
| 1491 | <ofdpa10:vni xc:operation="OPERATION"> |
macauley | 25999cf | 2015-08-07 17:03:24 +0800 | [diff] [blame] | 1492 | <ofdpa10:id>VNID</ofdpa10:id> |
| 1493 | </ofdpa10:vni> |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1494 | <ofdpa10:nexthop-id>NEXT_HOP_ID</ofdpa10:nexthop-id> |
| 1495 | <ofdpa10:ttl>TTL</ofdpa10:ttl> |
| 1496 | </ofdpa10:vtep> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1497 | </port> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1498 | </resources> |
| 1499 | <logical-switches> |
| 1500 | <switch> |
| 1501 | <id>DATAPATH_ID</id> |
| 1502 | <datapath-id>DATAPATH_ID</datapath-id> |
| 1503 | <resources> |
| 1504 | <port xc:operation="OPERATION">LPORT</port> |
| 1505 | </resources> |
| 1506 | </switch> |
| 1507 | </logical-switches> |
| 1508 | </capable-switch> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1509 | </config> |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1510 | """ |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1511 | str_datapath_id_f= "{:016x}".format(dp_id) |
| 1512 | str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)]) |
| 1513 | config_vtep_xml=config_vtep_xml.replace("DATAPATH_ID", str_datapath_id) |
macauley | 25999cf | 2015-08-07 17:03:24 +0800 | [diff] [blame] | 1514 | config_vtep_xml=config_vtep_xml.replace("LPORT", str(int(lport))) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1515 | config_vtep_xml=config_vtep_xml.replace("SRC_IP", str(src_ip)) |
| 1516 | config_vtep_xml=config_vtep_xml.replace("DST_IP", str(dst_ip)) |
| 1517 | config_vtep_xml=config_vtep_xml.replace("UDP_SRC_PORT", str(udp_src_port)) |
| 1518 | config_vtep_xml=config_vtep_xml.replace("NEXT_HOP_ID", str(next_hop_id)) |
| 1519 | config_vtep_xml=config_vtep_xml.replace("TTL", str(ttl)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1520 | config_vtep_xml=config_vtep_xml.replace("VNID", str(vnid)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1521 | config_vtep_xml=config_vtep_xml.replace("OPERATION", str(operation)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1522 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1523 | return config_vtep_xml |
| 1524 | |
| 1525 | def get_next_hop_config_xml(next_hop_id, dst_mac, phy_port, vlan, operation='merge'): |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1526 | #of-agent nexthop 2 destination user-input-dst-mac ethernet 1/2 vid 2 |
| 1527 | config_nexthop_xml=""" |
| 1528 | <config> |
| 1529 | <of11-config:capable-switch xmlns:of11-config="urn:onf:of111:config:yang" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> |
| 1530 | <ofdpa10:next-hop xmlns:ofdpa10="urn:bcm:ofdpa10:accton01" xc:operation="OPERATION"> |
| 1531 | <ofdpa10:id>NEXT_HOP_ID</ofdpa10:id> |
| 1532 | <ofdpa10:dest-mac>DST_MAC</ofdpa10:dest-mac> |
| 1533 | <ofdpa10:phy-port>PHY_PORT</ofdpa10:phy-port> |
| 1534 | <ofdpa10:vid>VLAN_ID</ofdpa10:vid> |
| 1535 | </ofdpa10:next-hop> |
| 1536 | </of11-config:capable-switch> |
| 1537 | </config> |
| 1538 | """ |
| 1539 | config_nexthop_xml=config_nexthop_xml.replace("VLAN_ID", str(vlan)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1540 | config_nexthop_xml=config_nexthop_xml.replace("PHY_PORT", str(phy_port)) |
| 1541 | config_nexthop_xml=config_nexthop_xml.replace("NEXT_HOP_ID", str(next_hop_id)) |
| 1542 | config_nexthop_xml=config_nexthop_xml.replace("DST_MAC", str(dst_mac)) |
| 1543 | config_nexthop_xml=config_nexthop_xml.replace("OPERATION", str(operation)) |
| 1544 | return config_nexthop_xml |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1545 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1546 | def get_vni_config_xml(vni_id, mcast_ipv4, next_hop_id, operation='merge'): |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1547 | #of-agent vni 10 multicast 224.1.1.1 nexthop 20 |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1548 | if mcast_ipv4!=None: |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1549 | config_vni_xml=""" |
| 1550 | <config> |
| 1551 | <of11-config:capable-switch xmlns:of11-config="urn:onf:of111:config:yang" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> |
| 1552 | <ofdpa10:vni xmlns:ofdpa10="urn:bcm:ofdpa10:accton01" xc:operation="OPERATION"> |
| 1553 | <ofdpa10:id>VNID</ofdpa10:id> |
| 1554 | <ofdpa10:vni-multicast-group>MCAST_IP</ofdpa10:vni-multicast-group> |
| 1555 | <ofdpa10:multicast-group-nexthop-id>NEXT_HOP_ID</ofdpa10:multicast-group-nexthop-id> |
| 1556 | </ofdpa10:vni> |
| 1557 | </of11-config:capable-switch> |
| 1558 | </config> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1559 | """ |
| 1560 | config_vni_xml=config_vni_xml.replace("NEXT_HOP_ID", str(next_hop_id)) |
| 1561 | config_vni_xml=config_vni_xml.replace("MCAST_IP", str(mcast_ipv4)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1562 | else: |
| 1563 | config_vni_xml=""" |
| 1564 | <config> |
| 1565 | <of11-config:capable-switch xmlns:of11-config="urn:onf:of111:config:yang" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> |
| 1566 | <ofdpa10:vni xmlns:ofdpa10="urn:bcm:ofdpa10:accton01" xc:operation="OPERATION"> |
| 1567 | <ofdpa10:id>VNID</ofdpa10:id> |
| 1568 | </ofdpa10:vni> |
| 1569 | </of11-config:capable-switch> |
| 1570 | </config> |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1571 | """ |
| 1572 | |
| 1573 | config_vni_xml=config_vni_xml.replace("VNID", str(vni_id)) |
| 1574 | config_vni_xml=config_vni_xml.replace("OPERATION", str(operation)) |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1575 | return config_vni_xml |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1576 | |
| 1577 | def get_featureReplay(self): |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1578 | req = ofp.message.features_request() |
| 1579 | res, raw = self.controller.transact(req) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1580 | self.assertIsNotNone(res, "Did not receive a response from the DUT.") |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1581 | self.assertEqual(res.type, ofp.OFPT_FEATURES_REPLY, |
| 1582 | ("Unexpected packet type %d received in response to " |
| 1583 | "OFPT_FEATURES_REQUEST") % res.type) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1584 | return res |
| 1585 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1586 | def send_edit_config(switch_ip, xml, target='runing'): |
| 1587 | NETCONF_ACCOUNT="netconfuser" |
| 1588 | NETCONF_PASSWD="netconfuser" |
| 1589 | with manager.connect_ssh(host=switch_ip, port=830, username=NETCONF_ACCOUNT, password=NETCONF_PASSWD, hostkey_verify=False ) as m: |
| 1590 | try: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1591 | m.edit_config(target='running', |
| 1592 | config=xml, |
| 1593 | default_operation='merge', |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1594 | error_option='stop-on-error') |
| 1595 | |
| 1596 | except Exception as e: |
| 1597 | logging.info("Fail to set xml %s", xml) |
| 1598 | return False |
| 1599 | |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1600 | #return m.get_config(source='running').data_xml |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1601 | return True |
| 1602 | |
| 1603 | def send_delete_config(switch_ip, xml, target='runing'): |
| 1604 | NETCONF_ACCOUNT="netconfuser" |
| 1605 | NETCONF_PASSWD="netconfuser" |
| 1606 | with manager.connect_ssh(host=switch_ip, port=830, username=NETCONF_ACCOUNT, password=NETCONF_PASSWD, hostkey_verify=False ) as m: |
| 1607 | try: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1608 | m.edit_config(target='running', |
| 1609 | config=xml, |
| 1610 | default_operation='delete', |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1611 | error_option='stop-on-error') |
| 1612 | |
| 1613 | except Exception as e: |
| 1614 | logging.info("Fail to set xml %s", xml) |
| 1615 | return False |
| 1616 | |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1617 | #return m.get_config(source='running').data_xml |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1618 | return True |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1619 | |
macauley | fddc466 | 2015-07-27 17:40:30 +0800 | [diff] [blame] | 1620 | def get_edit_config(switch_ip, target='runing'): |
| 1621 | NETCONF_ACCOUNT="netconfuser" |
| 1622 | NETCONF_PASSWD="netconfuser" |
| 1623 | with manager.connect_ssh(host=switch_ip, port=830, username=NETCONF_ACCOUNT, password=NETCONF_PASSWD, hostkey_verify=False ) as m: |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1624 | return m.get_config(source='running').data_xml |
macauley | dbff327 | 2015-07-30 14:07:16 +0800 | [diff] [blame] | 1625 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1626 | |
| 1627 | """ |
| 1628 | MPLS |
| 1629 | """ |
| 1630 | |
| 1631 | OFDPA_MPLS_SUBTYPE_SHIFT=24 |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1632 | OFDPA_MPLS_GROUP_SUBTYPE_L2_VPN_LABEL=1 |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1633 | OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL=2 |
| 1634 | OFDPA_MPLS_GROUP_SUBTYPE_TUNNEL_LABEL1=3 |
| 1635 | OFDPA_MPLS_GROUP_SUBTYPE_TUNNEL_LABEL2=4 |
| 1636 | OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL=5 |
| 1637 | OFDPA_MPLS_GROUP_SUBTYPE_FAST_FAILOVER_GROUP=6 |
| 1638 | OFDPA_MPLS_GROUP_SUBTYPE_ECMP=8 |
| 1639 | OFDPA_MPLS_GROUP_SUBTYPE_L2_TAG=10 |
| 1640 | |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 1641 | |
| 1642 | |
| 1643 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1644 | def encode_mpls_interface_group_id(subtype, index): |
| 1645 | index=index&0x00ffffff |
| 1646 | assert(subtype==0) |
| 1647 | return index + (9 << OFDPA_GROUP_TYPE_SHIFT)+(subtype<<OFDPA_MPLS_SUBTYPE_SHIFT) |
| 1648 | |
| 1649 | def encode_mpls_label_group_id(subtype, index): |
| 1650 | index=index&0x00ffffff |
| 1651 | assert(subtype <=5 or subtype==0) |
| 1652 | #1: l2 vpn label |
| 1653 | #2: l3 vpn label |
| 1654 | #3: mpls tunnel label 1 |
| 1655 | #4: mpls tunnel lable 2 |
| 1656 | #5: mpls swap label |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1657 | return index + (9 << OFDPA_GROUP_TYPE_SHIFT)+(subtype<<OFDPA_MPLS_SUBTYPE_SHIFT) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1658 | |
| 1659 | def encode_mpls_forwarding_group_id(subtype, index): |
| 1660 | index=index&0x00ffffff |
| 1661 | assert(subtype==6 or subtype==8 or subtype==10) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1662 | return index + (10 << OFDPA_GROUP_TYPE_SHIFT)+(subtype<<OFDPA_MPLS_SUBTYPE_SHIFT) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1663 | |
| 1664 | |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 1665 | def add_mpls_intf_group(ctrl, ref_gid, dst_mac, src_mac, vid, index, subtype=0, send_barrier=False): |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1666 | action=[] |
| 1667 | action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac))) |
| 1668 | action.append(ofp.action.set_field(ofp.oxm.eth_dst(dst_mac))) |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1669 | action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vid))) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1670 | action.append(ofp.action.group(ref_gid)) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1671 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1672 | buckets = [ofp.bucket(actions=action)] |
| 1673 | |
| 1674 | mpls_group_id =encode_mpls_interface_group_id(subtype, index) |
| 1675 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 1676 | group_id=mpls_group_id, |
| 1677 | buckets=buckets |
| 1678 | ) |
| 1679 | ctrl.message_send(request) |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 1680 | |
| 1681 | if send_barrier: |
| 1682 | do_barrier(ctrl) |
| 1683 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1684 | return mpls_group_id, request |
| 1685 | |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 1686 | def add_mpls_tunnel_label_group( |
| 1687 | ctrl, |
| 1688 | ref_gid, |
| 1689 | subtype, |
| 1690 | index, |
| 1691 | label, |
| 1692 | ): |
| 1693 | |
| 1694 | action=[] |
| 1695 | action.append(ofp.action.push_mpls(0x8847)) |
| 1696 | action.append(ofp.action.set_field(ofp.oxm.mpls_label(label))) |
| 1697 | action.append(ofp.action.group(ref_gid)) |
| 1698 | buckets = [ofp.bucket(actions=action)] |
| 1699 | |
| 1700 | mpls_group_id = encode_mpls_label_group_id(subtype, index) |
| 1701 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 1702 | group_id=mpls_group_id, |
| 1703 | buckets=buckets |
| 1704 | ) |
| 1705 | ctrl.message_send(request) |
| 1706 | |
| 1707 | return mpls_group_id, request |
| 1708 | |
Pier | b5da4c9 | 2016-09-21 11:23:35 -0700 | [diff] [blame] | 1709 | def add_mpls_swap_label_group( |
| 1710 | ctrl, |
| 1711 | ref_gid, |
| 1712 | subtype, |
| 1713 | index, |
| 1714 | label, |
| 1715 | ): |
| 1716 | |
| 1717 | action=[] |
| 1718 | action.append(ofp.action.set_field(ofp.oxm.mpls_label(label))) |
| 1719 | action.append(ofp.action.group(ref_gid)) |
| 1720 | buckets = [ofp.bucket(actions=action)] |
| 1721 | |
| 1722 | mpls_group_id = encode_mpls_label_group_id(subtype, index) |
| 1723 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 1724 | group_id=mpls_group_id, |
| 1725 | buckets=buckets |
| 1726 | ) |
| 1727 | ctrl.message_send(request) |
| 1728 | |
| 1729 | return mpls_group_id, request |
| 1730 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1731 | def add_mpls_label_group(ctrl, subtype, index, ref_gid, |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1732 | lmep_id=-1, |
| 1733 | qos_index=-1, |
| 1734 | push_l2_header=False, |
| 1735 | push_vlan=False, |
| 1736 | push_mpls_header=False, |
| 1737 | push_cw=False, |
| 1738 | set_mpls_label=None, |
| 1739 | set_bos=None, |
| 1740 | set_tc=None, |
| 1741 | set_tc_from_table=False, |
| 1742 | cpy_tc_outward=False, |
| 1743 | set_ttl=None, |
| 1744 | cpy_ttl_outward=False, |
| 1745 | oam_lm_tx_count=False, |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 1746 | set_pri_from_table=False, |
| 1747 | send_barrier=False |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1748 | ): |
| 1749 | """ |
| 1750 | @ref_gid: only can be mpls intf group or mpls tunnel label 1/2 group |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1751 | """ |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1752 | action=[] |
| 1753 | |
| 1754 | if push_vlan== True: |
| 1755 | action.append(ofp.action.push_vlan(0x8100)) |
| 1756 | if push_mpls_header== True: |
| 1757 | action.append(ofp.action.push_mpls(0x8847)) |
| 1758 | if set_mpls_label != None: |
| 1759 | action.append(ofp.action.set_field(ofp.oxm.mpls_label(set_mpls_label))) |
| 1760 | if set_bos != None: |
| 1761 | action.append(ofp.action.set_field(ofp.oxm.mpls_bos(set_bos))) |
| 1762 | if set_tc != None: |
| 1763 | assert(set_tc_from_table==False) |
| 1764 | action.append(ofp.action.set_field(ofp.oxm.mpls_tc(set_tc))) |
| 1765 | if set_ttl != None: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1766 | action.append(ofp.action.set_mpls_ttl(set_ttl)) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1767 | if cpy_ttl_outward == True: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1768 | action.append(ofp.action.copy_ttl_out()) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1769 | """ |
| 1770 | ofdpa experimenter |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1771 | """ |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1772 | if push_l2_header== True: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1773 | action.append(ofp.action.ofdpa_push_l2_header()) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1774 | if set_tc_from_table== True: |
| 1775 | assert(qos_index>=0) |
| 1776 | assert(set_tc == None) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1777 | action.append(ofp.action.ofdpa_set_tc_from_table(qos_index)) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1778 | if cpy_tc_outward == True: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1779 | action.append(ofp.action.ofdpa_copy_tc_out()) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1780 | if oam_lm_tx_count == True: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1781 | assert(qos_index>=0 and lmep_id>=0) |
| 1782 | action.append(ofp.action.ofdpa_oam_lm_tx_count(lmep_id, qos_index)) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1783 | if set_pri_from_table == True: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1784 | assert(qos_index>=0) |
| 1785 | action.append(ofp.action.ofdpa_set_qos_from_table(qos_index)) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1786 | if push_cw == True: |
| 1787 | action.append(ofp.action.ofdpa_push_cw()) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1788 | |
| 1789 | action.append(ofp.action.group(ref_gid)) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1790 | buckets = [ofp.bucket(actions=action)] |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1791 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1792 | mpls_group_id = encode_mpls_label_group_id(subtype, index) |
| 1793 | request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT, |
| 1794 | group_id=mpls_group_id, |
| 1795 | buckets=buckets |
| 1796 | ) |
| 1797 | ctrl.message_send(request) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1798 | |
Pier | 1e4e98e | 2016-10-26 14:36:05 -0700 | [diff] [blame] | 1799 | if send_barrier: |
| 1800 | do_barrier(ctrl) |
| 1801 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1802 | return mpls_group_id, request |
| 1803 | |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 1804 | def add_mpls_l2_port_flow(ctrl, of_port, mpls_l2_port, tunnel_index, ref_gid, qos_index=0): |
| 1805 | """ |
| 1806 | Only action is Group, which must indicate one of: |
| 1807 | MPLS L2 VPN Label or Fast Failover Protection Group. |
| 1808 | ref_gid contains this information |
| 1809 | """ |
| 1810 | tunnel_id = tunnel_index + ofp.oxm.TUNNEL_ID_BASE |
| 1811 | |
| 1812 | match = ofp.match() |
| 1813 | match.oxm_list.append(ofp.oxm.exp4ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_MPLS_L2_PORT, value=0x00000000 + of_port)) |
| 1814 | match.oxm_list.append(ofp.oxm.tunnel_id(tunnel_index + ofp.oxm.TUNNEL_ID_BASE)) |
| 1815 | |
Pier | 23784aa | 2016-09-19 20:08:21 -0700 | [diff] [blame] | 1816 | |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1817 | write_actions = [] |
| 1818 | write_actions.append(ofp.action.group(ref_gid)) |
| 1819 | apply_actions = [] |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 1820 | assert(qos_index>=0) |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1821 | apply_actions.append(ofp.action.set_field(ofp.oxm.exp1ByteValue(exp_type=ofp.oxm.OFDPA_EXP_TYPE_QOS_INDEX, value=qos_index))) |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 1822 | |
| 1823 | request = ofp.message.flow_add( |
| 1824 | table_id=MPLS_L2_PORT_FLOW_TABLE, |
| 1825 | cookie=42, |
| 1826 | match=match, |
| 1827 | instructions=[ |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1828 | ofp.instruction.apply_actions(actions=apply_actions), |
| 1829 | ofp.instruction.write_actions(actions=write_actions), |
| 1830 | ofp.instruction.goto_table(MPLS_L2_PORT_PCP_TRUST_FLOW_TABLE) |
| 1831 | ], |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 1832 | buffer_id=ofp.OFP_NO_BUFFER, |
| 1833 | priority=1) |
| 1834 | logging.info("Inserting flow %d mpls_l2_port, %d tunnel_id, action %x group and go to table %d", mpls_l2_port, tunnel_id, ref_gid, MPLS_L2_PORT_DSCP_TRUST_FLOW_TABLE) |
| 1835 | ctrl.message_send(request) |
| 1836 | return request |
| 1837 | |
| 1838 | return |
| 1839 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1840 | def add_mpls_forwarding_group(ctrl, subtype, index, ref_gids, |
| 1841 | watch_port=None, |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1842 | watch_group=ofp.OFPP_ANY, |
| 1843 | push_vlan=None, |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1844 | pop_vlan=None, |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1845 | set_vid=None): |
| 1846 | assert(subtype == OFDPA_MPLS_GROUP_SUBTYPE_FAST_FAILOVER_GROUP |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1847 | or subtype == OFDPA_MPLS_GROUP_SUBTYPE_ECMP |
| 1848 | or subtype == OFDPA_MPLS_GROUP_SUBTYPE_L2_TAG) |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1849 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1850 | buckets=[] |
| 1851 | if subtype == OFDPA_MPLS_GROUP_SUBTYPE_FAST_FAILOVER_GROUP: |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1852 | group_type = ofp.OFPGT_FF |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1853 | for gid in ref_gids: |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1854 | action=[] |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1855 | action.append(ofp.action.group(gid)) |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1856 | buckets.append(ofp.bucket(watch_port=watch_port, watch_group=watch_group,actions=action)) |
| 1857 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1858 | elif subtype == OFDPA_MPLS_GROUP_SUBTYPE_ECMP: |
| 1859 | group_type = ofp.OFPGT_SELECT |
| 1860 | for gid in ref_gids: |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1861 | action=[] |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1862 | action.append(ofp.action.group(gid)) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1863 | buckets.append(ofp.bucket(actions=action)) |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1864 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1865 | elif subtype == OFDPA_MPLS_GROUP_SUBTYPE_L2_TAG: |
| 1866 | group_type = ofp.OFPGT_INDIRECT |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1867 | action=[] |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1868 | if set_vid!=None: |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1869 | action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+set_vid))) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1870 | if push_vlan!=None: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1871 | action.append(ofp.action.push_vlan(push_vlan)) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1872 | if pop_vlan!=None: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1873 | action.append(ofp.action.pop_vlan()) |
| 1874 | action.append(ofp.action.group(ref_gids[0])) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1875 | buckets.append(ofp.bucket(actions=action)) |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1876 | |
| 1877 | mpls_group_id = encode_mpls_forwarding_group_id(subtype, index) |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1878 | request = ofp.message.group_add(group_type=group_type, |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1879 | group_id=mpls_group_id, |
| 1880 | buckets=buckets |
| 1881 | ) |
| 1882 | ctrl.message_send(request) |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1883 | return mpls_group_id, request |
macauley_cheng | d17ce51 | 2015-08-31 17:45:51 +0800 | [diff] [blame] | 1884 | |
| 1885 | |
macauley_cheng | 67da926 | 2015-08-31 15:18:41 +0800 | [diff] [blame] | 1886 | """ |
Pier | cf76e80 | 2016-09-19 20:16:35 -0700 | [diff] [blame] | 1887 | display |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1888 | """ |
macauley | dbff327 | 2015-07-30 14:07:16 +0800 | [diff] [blame] | 1889 | def print_current_table_flow_stat(ctrl, table_id=0xff): |
| 1890 | stat_req=ofp.message.flow_stats_request() |
| 1891 | response, pkt = ctrl.transact(stat_req) |
| 1892 | if response == None: |
| 1893 | print "no response" |
| 1894 | return None |
| 1895 | print len(response.entries) |
| 1896 | for obj in response.entries: |
| 1897 | print "match ", obj.match |
| 1898 | print "cookie", obj.cookie |
| 1899 | print "priority", obj.priority |
| 1900 | print "idle_timeout", obj.idle_timeout |
| 1901 | print "hard_timeout", obj.hard_timeout |
| 1902 | #obj.actions |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 1903 | print "packet count: %lx"%obj.packet_count |