Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
tom
2014-10-01 16:51:53 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
53af33b4ee9bcf4996673e950fa3218d682d060a
53af33b4
2 parents
2482e6ff
1f641c0b
Merge remote-tracking branch 'origin/master'
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
69 additions
and
23 deletions
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
core/net/src/main/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManager.java
openflow/api/src/main/java/org/onlab/onos/openflow/controller/DefaultOpenFlowPacketContext.java
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/DriverManager.java
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowRuleBuilder.java
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
providers/openflow/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
providers/openflow/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java
utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
apps/fwd/src/main/java/org/onlab/onos/fwd/ReactiveForwarding.java
View file @
53af33b
...
...
@@ -100,6 +100,7 @@ public class ReactiveForwarding {
context
.
block
();
return
;
}
HostId
id
=
HostId
.
hostId
(
ethPkt
.
getDestinationMAC
());
// Do we know who this is for? If not, flood and bail.
...
...
@@ -112,7 +113,9 @@ public class ReactiveForwarding {
// Are we on an edge switch that our destination is on? If so,
// simply forward out to the destination and bail.
if
(
pkt
.
receivedFrom
().
deviceId
().
equals
(
dst
.
location
().
deviceId
()))
{
if
(!
context
.
inPacket
().
receivedFrom
().
port
().
equals
(
dst
.
location
().
port
()))
{
installRule
(
context
,
dst
.
location
().
port
());
}
return
;
}
...
...
@@ -175,6 +178,8 @@ public class ReactiveForwarding {
// We don't yet support bufferids in the flowservice so packet out first.
packetOut
(
context
,
portNumber
);
if
(
context
.
inPacket
().
parsed
().
getEtherType
()
==
Ethernet
.
TYPE_IPV4
)
{
// Install the flow rule to handle this type of message from now on.
Ethernet
inPkt
=
context
.
inPacket
().
parsed
();
TrafficSelector
.
Builder
builder
=
new
DefaultTrafficSelector
.
Builder
();
...
...
@@ -191,6 +196,7 @@ public class ReactiveForwarding {
flowRuleService
.
applyFlowRules
(
f
);
}
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
View file @
53af33b
...
...
@@ -27,9 +27,11 @@ public class DefaultFlowRule implements FlowRule {
private
final
ApplicationId
appId
;
private
boolean
expired
;
public
DefaultFlowRule
(
DeviceId
deviceId
,
TrafficSelector
selector
,
TrafficTreatment
treatment
,
int
priority
,
FlowRuleState
state
,
long
life
,
long
packets
,
long
bytes
,
long
flowId
)
{
long
life
,
long
packets
,
long
bytes
,
long
flowId
,
boolean
expired
)
{
this
.
deviceId
=
deviceId
;
this
.
priority
=
priority
;
this
.
selector
=
selector
;
...
...
@@ -37,7 +39,7 @@ public class DefaultFlowRule implements FlowRule {
this
.
state
=
state
;
this
.
appId
=
ApplicationId
.
valueOf
((
int
)
(
flowId
>>
32
));
this
.
id
=
FlowId
.
valueOf
(
flowId
);
this
.
expired
=
expired
;
this
.
life
=
life
;
this
.
packets
=
packets
;
this
.
bytes
=
bytes
;
...
...
@@ -186,4 +188,9 @@ public class DefaultFlowRule implements FlowRule {
.
toString
();
}
@Override
public
boolean
expired
()
{
return
expired
;
}
}
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowRule.java
View file @
53af33b
...
...
@@ -111,4 +111,11 @@ public interface FlowRule {
*/
long
bytes
();
/**
* Indicates that this flow has expired at the device.
*
* @return true if it has expired, false otherwise
*/
boolean
expired
();
}
...
...
core/net/src/main/java/org/onlab/onos/net/flow/impl/FlowRuleManager.java
View file @
53af33b
...
...
@@ -161,7 +161,11 @@ implements FlowRuleService, FlowRuleProviderRegistry {
switch
(
stored
.
state
())
{
case
ADDED:
case
PENDING_ADD:
if
(
flowRule
.
expired
())
{
event
=
store
.
removeFlowRule
(
flowRule
);
}
else
{
frp
.
applyFlowRule
(
stored
);
}
break
;
case
PENDING_REMOVE:
case
REMOVED:
...
...
core/net/src/main/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManager.java
View file @
53af33b
...
...
@@ -231,6 +231,7 @@ public class ProxyArpManager implements ProxyArpService {
arp
.
setOpCode
(
ARP
.
OP_REPLY
);
arp
.
setProtocolType
(
ARP
.
PROTO_TYPE_IP
);
arp
.
setHardwareType
(
ARP
.
HW_TYPE_ETHERNET
);
arp
.
setProtocolAddressLength
((
byte
)
IpPrefix
.
INET_LEN
);
arp
.
setHardwareAddressLength
((
byte
)
Ethernet
.
DATALAYER_ADDRESS_LENGTH
);
arp
.
setSenderHardwareAddress
(
h
.
mac
().
getAddress
());
...
...
@@ -238,7 +239,7 @@ public class ProxyArpManager implements ProxyArpService {
arp
.
setTargetProtocolAddress
(((
ARP
)
request
.
getPayload
())
.
getSenderProtocolAddress
());
arp
.
setSenderProtocolAddress
(
h
.
ipAddresses
().
iterator
().
next
().
toInt
());
arp
.
setSenderProtocolAddress
(
h
.
ipAddresses
().
iterator
().
next
().
to
Real
Int
());
eth
.
setPayload
(
arp
);
return
eth
;
}
...
...
@@ -291,7 +292,6 @@ public class ProxyArpManager implements ProxyArpService {
case
DEVICE_MASTERSHIP_CHANGED:
case
DEVICE_SUSPENDED:
case
DEVICE_UPDATED:
case
PORT_UPDATED:
// nothing to do in these cases; handled when links get reported
break
;
case
DEVICE_REMOVED:
...
...
@@ -301,10 +301,13 @@ public class ProxyArpManager implements ProxyArpService {
}
break
;
case
PORT_ADDED:
case
PORT_UPDATED:
synchronized
(
externalPorts
)
{
if
(
event
.
port
().
isEnabled
())
{
externalPorts
.
put
(
device
,
event
.
port
().
number
());
internalPorts
.
remove
(
device
,
event
.
port
().
number
());
}
}
break
;
case
PORT_REMOVED:
synchronized
(
externalPorts
)
{
...
...
openflow/api/src/main/java/org/onlab/onos/openflow/controller/DefaultOpenFlowPacketContext.java
View file @
53af33b
...
...
@@ -48,7 +48,7 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
OFPacketOut
.
Builder
builder
=
sw
.
factory
().
buildPacketOut
();
OFAction
act
=
buildOutput
(
outPort
.
getPortNumber
());
pktout
=
builder
.
setXid
(
pktin
.
getXid
())
.
setInPort
(
pktin
.
getInP
ort
())
.
setInPort
(
inp
ort
())
.
setBufferId
(
pktin
.
getBufferId
())
.
setActions
(
Collections
.
singletonList
(
act
))
.
build
();
...
...
@@ -63,7 +63,7 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
OFAction
act
=
buildOutput
(
outPort
.
getPortNumber
());
pktout
=
builder
.
setXid
(
pktin
.
getXid
())
.
setBufferId
(
OFBufferId
.
NO_BUFFER
)
.
setInPort
(
pktin
.
getInP
ort
())
.
setInPort
(
inp
ort
())
.
setActions
(
Collections
.
singletonList
(
act
))
.
setData
(
ethFrame
.
serialize
())
.
build
();
...
...
@@ -88,10 +88,16 @@ public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext
@Override
public
Integer
inPort
()
{
return
inport
().
getPortNumber
();
}
private
OFPort
inport
()
{
//FIXME: this has to change in fucking loxi
try
{
return
pktin
.
getInPort
()
.
getPortNumber
()
;
return
pktin
.
getInPort
();
}
catch
(
UnsupportedOperationException
e
)
{
return
pktin
.
getMatch
().
get
(
MatchField
.
IN_PORT
)
.
getPortNumber
()
;
return
pktin
.
getMatch
().
get
(
MatchField
.
IN_PORT
);
}
}
...
...
openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/OFChannelHandler.java
View file @
53af33b
...
...
@@ -651,7 +651,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
* @param error The error message
*/
protected
void
logError
(
OFChannelHandler
h
,
OFErrorMsg
error
)
{
log
.
debug
(
"{} from switch {} in state {}"
,
log
.
info
(
"{} from switch {} in state {}"
,
new
Object
[]
{
error
,
h
.
getSwitchInfoString
(),
...
...
openflow/ctl/src/main/java/org/onlab/onos/openflow/drivers/impl/DriverManager.java
View file @
53af33b
...
...
@@ -6,6 +6,7 @@ import java.util.Collections;
import
java.util.List
;
import
org.onlab.onos.openflow.controller.Dpid
;
import
org.onlab.onos.openflow.controller.RoleState
;
import
org.onlab.onos.openflow.controller.driver.AbstractOpenFlowSwitch
;
import
org.onlab.onos.openflow.controller.driver.OpenFlowSwitchDriver
;
import
org.onlab.onos.openflow.controller.driver.OpenFlowSwitchDriverFactory
;
...
...
@@ -61,6 +62,11 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory {
return
new
AbstractOpenFlowSwitch
(
dpid
,
desc
)
{
@Override
public
void
setRole
(
RoleState
state
)
{
this
.
role
=
RoleState
.
MASTER
;
}
@Override
public
void
write
(
List
<
OFMessage
>
msgs
)
{
channel
.
write
(
msgs
);
}
...
...
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowModBuilder.java
View file @
53af33b
...
...
@@ -73,7 +73,7 @@ public class FlowModBuilder {
List
<
OFAction
>
actions
=
buildActions
();
//TODO: what to do without bufferid? do we assume that there will be a pktout as well?
OFFlowMod
fm
=
factory
.
buildFlow
Modify
()
OFFlowMod
fm
=
factory
.
buildFlow
Add
()
.
setCookie
(
U64
.
of
(
cookie
.
value
()))
.
setBufferId
(
OFBufferId
.
NO_BUFFER
)
.
setActions
(
actions
)
...
...
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/FlowRuleBuilder.java
View file @
53af33b
...
...
@@ -18,6 +18,7 @@ import org.onlab.packet.IpPrefix;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.VlanId
;
import
org.projectfloodlight.openflow.protocol.OFFlowRemoved
;
import
org.projectfloodlight.openflow.protocol.OFFlowRemovedReason
;
import
org.projectfloodlight.openflow.protocol.OFFlowStatsEntry
;
import
org.projectfloodlight.openflow.protocol.action.OFAction
;
import
org.projectfloodlight.openflow.protocol.action.OFActionOutput
;
...
...
@@ -70,14 +71,15 @@ public class FlowRuleBuilder {
buildSelector
(),
buildTreatment
(),
stat
.
getPriority
(),
FlowRuleState
.
ADDED
,
stat
.
getDurationNsec
()
/
1000000
,
stat
.
getPacketCount
().
getValue
(),
stat
.
getByteCount
().
getValue
(),
stat
.
getCookie
().
getValue
());
stat
.
getCookie
().
getValue
()
,
false
);
}
else
{
// TODO: revisit potentially.
return
new
DefaultFlowRule
(
DeviceId
.
deviceId
(
Dpid
.
uri
(
dpid
)),
buildSelector
(),
null
,
removed
.
getPriority
(),
FlowRuleState
.
REMOVED
,
removed
.
getDurationNsec
()
/
1000000
,
removed
.
getPacketCount
().
getValue
(),
removed
.
getByteCount
().
getValue
(),
removed
.
getCookie
().
getValue
());
removed
.
getCookie
().
getValue
(),
removed
.
getReason
()
==
OFFlowRemovedReason
.
IDLE_TIMEOUT
.
ordinal
());
}
}
...
...
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
View file @
53af33b
...
...
@@ -158,7 +158,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
case
BARRIER_REPLY:
case
ERROR:
default
:
log
.
warn
(
"Unhandled message type: {}"
,
msg
.
getType
());
log
.
debug
(
"Unhandled message type: {}"
,
msg
.
getType
());
}
}
...
...
providers/openflow/link/src/main/java/org/onlab/onos/provider/of/link/impl/LinkDiscovery.java
View file @
53af33b
...
...
@@ -131,7 +131,7 @@ public class LinkDiscovery implements TimerTask {
}
timeout
=
Timer
.
getTimer
().
newTimeout
(
this
,
0
,
TimeUnit
.
MILLISECONDS
);
this
.
log
.
debug
(
"Started discovery manager for switch {}"
,
this
.
log
.
info
(
"Started discovery manager for switch {}"
,
sw
.
getId
());
}
...
...
providers/openflow/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
View file @
53af33b
package
org
.
onlab
.
onos
.
provider
.
of
.
packet
.
impl
;
import
static
org
.
onlab
.
onos
.
openflow
.
controller
.
RoleState
.
SLAVE
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
java.nio.ByteBuffer
;
...
...
@@ -95,9 +94,6 @@ public class OpenFlowPacketProvider extends AbstractProvider implements PacketPr
if
(
sw
==
null
)
{
log
.
warn
(
"Device {} isn't available?"
,
devId
);
return
;
}
else
if
(
sw
.
getRole
().
equals
(
SLAVE
))
{
log
.
warn
(
"Can't write to Device {} as slave"
,
devId
);
return
;
}
Ethernet
eth
=
new
Ethernet
();
...
...
providers/openflow/packet/src/test/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProviderTest.java
View file @
53af33b
...
...
@@ -140,12 +140,12 @@ public class OpenFlowPacketProviderTest {
sw
.
sent
.
clear
();
//wrong Role
sw
.
setRole
(
RoleState
.
SLAVE
);
provider
.
emit
(
passPkt
);
assertEquals
(
"invalid switch"
,
sw
,
controller
.
current
);
assertEquals
(
"message sent incorrectly"
,
0
,
sw
.
sent
.
size
());
//
sw.setRole(RoleState.SLAVE);
//
provider.emit(passPkt);
//
assertEquals("invalid switch", sw, controller.current);
//
assertEquals("message sent incorrectly", 0, sw.sent.size());
sw
.
setRole
(
RoleState
.
MASTER
);
//
sw.setRole(RoleState.MASTER);
//missing switch
OutboundPacket
swFailPkt
=
outPacket
(
DID_MISSING
,
TR
,
eth
);
...
...
utils/misc/src/main/java/org/onlab/packet/IpPrefix.java
View file @
53af33b
...
...
@@ -180,6 +180,15 @@ public final class IpPrefix {
return
address
;
}
public
int
toRealInt
()
{
int
val
=
0
;
for
(
int
i
=
0
;
i
<
octets
.
length
;
i
++)
{
val
<<=
8
;
val
|=
octets
[
i
]
&
0xff
;
}
return
val
;
}
/**
* Helper for computing the mask value from CIDR.
*
...
...
Please
register
or
login
to post a comment