Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
7e869bbc
Commit
7e869bbc
authored
10 years ago
by
sanjivininaikar
Browse files
Options
Downloads
Patches
Plain Diff
Update StaticFlowEntryPusherResource.java
Suggested changes made
parent
bb497f4f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/staticflowentry/web/StaticFlowEntryPusherResource.java
+198
-170
198 additions, 170 deletions
...er/staticflowentry/web/StaticFlowEntryPusherResource.java
with
198 additions
and
170 deletions
src/main/java/net/floodlightcontroller/staticflowentry/web/StaticFlowEntryPusherResource.java
+
198
−
170
View file @
7e869bbc
...
...
@@ -31,6 +31,7 @@ import net.floodlightcontroller.core.annotations.LogMessageDoc;
import
net.floodlightcontroller.staticflowentry.StaticFlowEntries
;
import
net.floodlightcontroller.staticflowentry.StaticFlowEntryPusher
;
import
net.floodlightcontroller.storage.IStorageSourceService
;
import
net.floodlightcontroller.util.MatchUtils
;
/**
* Pushes a static flow entry to the storage source
...
...
@@ -41,130 +42,128 @@ import net.floodlightcontroller.storage.IStorageSourceService;
public
class
StaticFlowEntryPusherResource
extends
ServerResource
{
protected
static
Logger
log
=
LoggerFactory
.
getLogger
(
StaticFlowEntryPusherResource
.
class
);
/**
* Validates if all the mandatory fields are set properly while adding an IPv6 flow
* @param Map containing the fields of the flow
* @return state indicating whether a flow is valid or not
*/
private
int
checkMatch
(
Map
<
String
,
Object
>
rows
)
{
//sanjivini
//Declaring & Initializing flags
int
state
=
0
;
boolean
dl_type
=
false
;
boolean
nw_proto
=
false
;
boolean
nw_layer
=
false
;
boolean
icmp6_type
=
false
;
boolean
icmp6_code
=
false
;
boolean
nd_target
=
false
;
boolean
nd_sll
=
false
;
boolean
nd_tll
=
false
;
boolean
ip6
=
false
;
boolean
ip4
=
false
;
String
eth_type
=
null
;
String
nw_protocol
=
null
;
int
icmp_type
=
-
1
;
//Determine the dl_type if set
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_DL_TYPE
))
{
dl_type
=
true
;
eth_type
=
(
String
)
rows
.
get
(
StaticFlowEntryPusher
.
COLUMN_DL_TYPE
);
if
(
eth_type
.
equalsIgnoreCase
(
"0x86dd"
)
||
eth_type
.
equals
(
"34525"
))
{
ip6
=
true
;
}
else
if
(
eth_type
.
equalsIgnoreCase
(
"0x800"
)
||
eth_type
.
equals
(
"2048"
)||
/**
* Validates if all the mandatory fields are set properly while adding an IPv6 flow
* @param Map containing the fields of the flow
* @return state indicating whether a flow is valid or not
*/
private
int
checkFlow
(
Map
<
String
,
Object
>
rows
)
{
//Declaring & Initializing flags
int
state
=
0
;
boolean
dl_type
=
false
;
boolean
nw_proto
=
false
;
boolean
nw_layer
=
false
;
boolean
icmp6_type
=
false
;
boolean
icmp6_code
=
false
;
boolean
nd_target
=
false
;
boolean
nd_sll
=
false
;
boolean
nd_tll
=
false
;
boolean
ip6
=
false
;
boolean
ip4
=
false
;
String
eth_type
=
null
;
String
nw_protocol
=
null
;
int
icmp_type
=
-
1
;
//Determine the dl_type if set
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_DL_TYPE
))
{
dl_type
=
true
;
eth_type
=
(
String
)
rows
.
get
(
StaticFlowEntryPusher
.
COLUMN_DL_TYPE
);
if
(
eth_type
.
equalsIgnoreCase
(
"0x86dd"
)
||
eth_type
.
equals
(
"34525"
))
{
ip6
=
true
;
}
else
if
(
eth_type
.
equalsIgnoreCase
(
"0x800"
)
||
eth_type
.
equals
(
"2048"
)||
eth_type
.
equalsIgnoreCase
(
"0x806"
)
||
eth_type
.
equals
(
"2054"
))
{
ip4
=
true
;
}
else
{
state
=
2
;
return
state
;
}
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW_DST
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW_SRC
))
{
nw_layer
=
true
;
ip4
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP_CODE
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP_TYPE
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_DHA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_SHA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_SPA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_DPA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_OPCODE
))
{
ip4
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_IPV6_FLOW_LABEL
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW6_SRC
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW6_DST
)
)
{
nw_layer
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW_PROTO
))
{
nw_proto
=
true
;
nw_protocol
=
(
String
)
rows
.
get
(
StaticFlowEntryPusher
.
COLUMN_NW_PROTO
);
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP6_CODE
))
{
icmp6_code
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP6_TYPE
))
{
icmp6_type
=
true
;
ip6
=
true
;
icmp_type
=
Integer
.
parseInt
((
String
)
rows
.
get
(
StaticFlowEntryPusher
.
COLUMN_ICMP6_TYPE
));
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ND_SLL
))
{
nd_sll
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ND_TLL
))
{
nd_tll
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ND_TARGET
))
{
nd_target
=
true
;
ip6
=
true
;
}
if
(
nw_layer
==
true
||
nw_proto
==
true
)
{
if
(
dl_type
==
true
)
{
if
(!(
ip4
==
true
||
ip6
==
true
))
{
//invalid dl_type
state
=
2
;
return
state
;
}
}
else
{
//dl_type not set
state
=
1
;
return
state
;
}
}
if
(
icmp6_type
==
true
||
icmp6_code
==
true
)
{
if
(
nw_proto
==
true
)
{
if
(!(
nw_protocol
.
equals
(
"58"
)
||
nw_protocol
.
equalsIgnoreCase
(
"0x3A"
)))
{
//invalid nw_proto
state
=
4
;
return
state
;
}
}
else
{
//nw_proto not set
state
=
3
;
return
state
;
}
}
if
(
nd_sll
==
true
||
nd_tll
==
true
||
nd_target
==
true
)
{
if
(
icmp6_type
==
true
)
{
//icmp_type must be set to 135/136 to set ipv6_nd_target
ip4
=
true
;
}
//else {
// state = 2;
// return state;
//}
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW_DST
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW_SRC
))
{
nw_layer
=
true
;
ip4
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP_CODE
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP_TYPE
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_DHA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_SHA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_SPA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_DPA
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ARP_OPCODE
))
{
ip4
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_IPV6_FLOW_LABEL
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW6_SRC
)
||
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW6_DST
))
{
nw_layer
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_NW_PROTO
))
{
nw_proto
=
true
;
nw_protocol
=
(
String
)
rows
.
get
(
StaticFlowEntryPusher
.
COLUMN_NW_PROTO
);
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP6_CODE
))
{
icmp6_code
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ICMP6_TYPE
))
{
icmp6_type
=
true
;
ip6
=
true
;
icmp_type
=
Integer
.
parseInt
((
String
)
rows
.
get
(
StaticFlowEntryPusher
.
COLUMN_ICMP6_TYPE
));
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ND_SLL
))
{
nd_sll
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ND_TLL
))
{
nd_tll
=
true
;
ip6
=
true
;
}
if
(
rows
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ND_TARGET
))
{
nd_target
=
true
;
ip6
=
true
;
}
if
(
nw_layer
==
true
||
nw_proto
==
true
)
{
if
(
dl_type
==
true
)
{
if
(!(
ip4
==
true
||
ip6
==
true
))
{
//invalid dl_type
state
=
2
;
return
state
;
}
}
else
{
//dl_type not set
state
=
1
;
return
state
;
}
}
if
(
icmp6_type
==
true
||
icmp6_code
==
true
)
{
if
(
nw_proto
==
true
)
{
if
(!(
nw_protocol
.
equals
(
"58"
)
||
nw_protocol
.
equalsIgnoreCase
(
"0x3A"
)))
{
//invalid nw_proto
state
=
4
;
return
state
;
}
}
else
{
//nw_proto not set
state
=
3
;
return
state
;
}
}
if
(
nd_sll
==
true
||
nd_tll
==
true
||
nd_target
==
true
)
{
if
(
icmp6_type
==
true
)
{
//icmp_type must be set to 135/136 to set ipv6_nd_target
if
(
nd_target
==
true
)
{
if
(!(
icmp_type
==
135
||
icmp_type
==
136
))
{
//invalid icmp6_type
state
=
6
;
state
=
6
;
return
state
;
}
}
...
...
@@ -172,7 +171,7 @@ public class StaticFlowEntryPusherResource extends ServerResource {
else
if
(
nd_tll
==
true
)
{
if
(!(
icmp_type
==
136
))
{
//invalid icmp6_type
state
=
6
;
state
=
6
;
return
state
;
}
}
...
...
@@ -180,58 +179,87 @@ public class StaticFlowEntryPusherResource extends ServerResource {
else
if
(
nd_sll
==
true
)
{
if
(!(
icmp_type
==
135
))
{
//invalid icmp6_type
state
=
6
;
state
=
6
;
return
state
;
}
}
}
else
{
//icmp6_type not set
state
=
5
;
return
state
;
}
}
if
((
ip4
==
true
&&
ip6
==
true
)
||
(
StaticFlowEntries
.
ip4
==
true
&&
StaticFlowEntries
.
ip6
==
true
)
||
(
StaticFlowEntries
.
ip4
==
true
&&
ip6
==
true
)
||
(
StaticFlowEntries
.
ip6
==
true
&&
ip4
==
true
))
{
//ipv4 & ipv6 conflict
state
=
7
;
return
state
;
}
return
state
;
//sanjivini
/*
boolean matchEther = false;
String val = (String) rows.get(StaticFlowEntryPusher.COLUMN_DL_TYPE);
if (val != null) {
int type = 0;
// check both hex and decimal
if (val.startsWith("0x")) {
type = Integer.parseInt(val.substring(2), 16);
} else {
try {
type = Integer.parseInt(val);
} catch (NumberFormatException e) { /* fail silently */
/*}
}
if ((type == 2048)|| (type == 34525)) matchEther = true;
}
if ((rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_DST) ||
rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_SRC) ||
rows.containsKey(StaticFlowEntryPusher.COLUMN_NW6_SRC) ||
rows.containsKey(StaticFlowEntryPusher.COLUMN_NW6_DST) ||
rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_PROTO) ||
rows.containsKey(StaticFlowEntryPusher.COLUMN_NW_TOS)) &&
(matchEther == false))
return false;
}
else
{
//icmp6_type not set
state
=
5
;
return
state
;
}
}
int
result
=
checkActions
(
rows
);
if
((
ip4
==
true
&&
ip6
==
true
)
||
(
result
==
-
1
)
||
(
result
==
1
&&
ip6
==
true
)
||
(
result
==
2
&&
ip4
==
true
))
{
//ipv4 & ipv6 conflict
state
=
7
;
return
state
;
}
return
state
;
}
/**
* Validates actions/instructions
*
* -1 --> IPv4/IPv6 conflict
* 0 --> no IPv4 or IPv6 actions
* 1 --> IPv4 only actions
* 2 --> IPv6 only actions
*
* @param Map containing the fields of the flow
* @return state indicating whether a flow is valid or not
*/
public
static
int
checkActions
(
Map
<
String
,
Object
>
entry
)
{
boolean
ip6
=
false
;
boolean
ip4
=
false
;
String
actions
=
null
;
if
(
entry
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ACTIONS
)
||
entry
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_INSTR_APPLY_ACTIONS
)
||
entry
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_INSTR_WRITE_ACTIONS
))
{
if
(
entry
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_ACTIONS
))
{
actions
=
(
String
)
entry
.
get
(
StaticFlowEntryPusher
.
COLUMN_ACTIONS
);
}
else
if
(
entry
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_INSTR_APPLY_ACTIONS
))
{
actions
=
(
String
)
entry
.
get
(
StaticFlowEntryPusher
.
COLUMN_INSTR_APPLY_ACTIONS
);
}
else
if
(
entry
.
containsKey
(
StaticFlowEntryPusher
.
COLUMN_INSTR_WRITE_ACTIONS
))
{
actions
=
(
String
)
entry
.
get
(
StaticFlowEntryPusher
.
COLUMN_INSTR_WRITE_ACTIONS
);
}
if
(
actions
.
contains
(
MatchUtils
.
STR_ICMPV6_CODE
)
||
actions
.
contains
(
MatchUtils
.
STR_ICMPV6_TYPE
)
||
actions
.
contains
(
MatchUtils
.
STR_IPV6_DST
)
||
actions
.
contains
(
MatchUtils
.
STR_IPV6_SRC
)
||
actions
.
contains
(
MatchUtils
.
STR_IPV6_FLOW_LABEL
)
||
actions
.
contains
(
MatchUtils
.
STR_IPV6_ND_SSL
)
||
actions
.
contains
(
MatchUtils
.
STR_IPV6_ND_TARGET
)
||
actions
.
contains
(
MatchUtils
.
STR_IPV6_ND_TTL
))
{
ip6
=
true
;
}
if
(
actions
.
contains
(
MatchUtils
.
STR_NW_SRC
)
||
actions
.
contains
(
MatchUtils
.
STR_NW_DST
)
||
actions
.
contains
(
MatchUtils
.
STR_ARP_OPCODE
)
||
actions
.
contains
(
MatchUtils
.
STR_ARP_SHA
)
||
actions
.
contains
(
MatchUtils
.
STR_ARP_DHA
)
||
actions
.
contains
(
MatchUtils
.
STR_ARP_SPA
)
||
actions
.
contains
(
MatchUtils
.
STR_ARP_DPA
)
||
actions
.
contains
(
MatchUtils
.
STR_ICMP_CODE
)
||
actions
.
contains
(
MatchUtils
.
STR_ICMP_TYPE
))
{
ip4
=
true
;
}
}
if
(
ip6
==
false
&&
ip4
==
false
)
{
return
0
;
// no actions involving ipv4 or ipv6
}
else
if
(
ip6
==
false
&&
ip4
==
true
)
{
return
1
;
//ipv4
}
else
if
(
ip6
==
true
&&
ip4
==
false
)
{
return
2
;
//ipv6
}
else
{
return
-
1
;
// conflict of ipv4 and ipv6 actions
}
}
return true;
*/
}
/**
* Takes a Static Flow Pusher string in JSON format and parses it into
...
...
@@ -253,7 +281,7 @@ public class StaticFlowEntryPusherResource extends ServerResource {
try
{
rowValues
=
StaticFlowEntries
.
jsonToStorageEntry
(
fmJson
);
String
status
=
null
;
int
state
=
check
Match
(
rowValues
);
int
state
=
check
Flow
(
rowValues
);
if
(
state
==
1
)
{
status
=
"Warning! Must specify eth_type of IPv4/IPv6 to "
+
"match on IPv4/IPv6 fields! The flow has been discarded."
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment