trema 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -1
- data/Doxyfile +1 -1
- data/Gemfile +18 -6
- data/README.md +112 -5
- data/Rakefile +3 -1
- data/Rantfile +88 -1
- data/bin/trema +248 -0
- data/bin/trema-config +59 -0
- data/cruise.rb +1 -1
- data/features/example.dumper.feature +45 -65
- data/features/example.hello_trema.feature +21 -0
- data/features/example.learning_switch.feature +26 -28
- data/features/example.list_switches.feature +19 -33
- data/features/example.message.echo_reply.feature +10 -10
- data/features/example.message.echo_request.feature +2 -2
- data/features/example.message.features_request.feature +6 -5
- data/features/example.message.hello.feature +47 -13
- data/features/example.message.set_config.feature +4 -4
- data/features/example.message.vendor-action.feature +23 -0
- data/features/example.multi_learning_switch.feature +14 -42
- data/features/example.packet_in.feature +31 -0
- data/features/example.packetin_filter_config.feature +11 -7
- data/features/example.patch_panel.feature +29 -0
- data/features/example.repeater_hub.feature +43 -40
- data/features/example.switch_info.feature +51 -0
- data/features/example.switch_monitor.feature +24 -42
- data/features/packetin_filter.feature +28 -22
- data/features/step_definitions/misc_steps.rb +19 -8
- data/features/step_definitions/send_packets_steps.rb +1 -10
- data/features/step_definitions/stats_steps.rb +4 -4
- data/features/support/env.rb +2 -1
- data/features/support/hooks.rb +35 -2
- data/features/switch_manager.feature +18 -12
- data/features/trema-config.feature +26 -39
- data/features/trema.dump_flows.feature +26 -12
- data/features/trema.help.feature +26 -0
- data/features/trema.kill.feature +39 -41
- data/features/trema.killall.feature +23 -23
- data/features/trema.reset_stats.feature +50 -10
- data/features/trema.run.feature +28 -39
- data/features/trema.send_packets.feature +29 -40
- data/features/trema.show_stats.feature +30 -33
- data/features/trema.up.feature +33 -0
- data/features/trema.version.feature +9 -0
- data/ruby/extconf.rb +7 -0
- data/ruby/trema/aggregate-stats-reply.rb +3 -3
- data/ruby/trema/app.rb +5 -1
- data/ruby/trema/barrier-request.c +55 -30
- data/ruby/trema/cli.rb +8 -8
- data/ruby/trema/command.rb +1 -3
- data/ruby/trema/command/dump_flows.rb +5 -24
- data/ruby/trema/command/kill.rb +31 -36
- data/ruby/trema/command/killall.rb +1 -19
- data/{features/step_definitions/kill_steps.rb → ruby/trema/command/netns.rb} +13 -5
- data/ruby/trema/command/reset_stats.rb +3 -23
- data/ruby/trema/command/ruby.rb +2 -19
- data/ruby/trema/command/run.rb +6 -27
- data/ruby/trema/command/send_packets.rb +6 -90
- data/ruby/trema/command/show_stats.rb +21 -40
- data/ruby/trema/command/up.rb +5 -26
- data/ruby/trema/command/version.rb +1 -5
- data/ruby/trema/controller.c +14 -16
- data/ruby/trema/custom-switch.rb +56 -0
- data/ruby/trema/desc-stats-reply.rb +5 -5
- data/ruby/trema/dsl/configuration.rb +4 -0
- data/{features/step_definitions/up_steps.rb → ruby/trema/dsl/custom-switch.rb} +18 -4
- data/ruby/trema/dsl/netns.rb +78 -0
- data/ruby/trema/dsl/parser.rb +2 -0
- data/ruby/trema/dsl/runner.rb +8 -0
- data/ruby/trema/dsl/syntax.rb +18 -0
- data/ruby/trema/echo-reply.h +2 -2
- data/ruby/trema/echo-request.c +3 -5
- data/ruby/trema/enqueue.rb +2 -2
- data/ruby/trema/error.c +3 -3
- data/ruby/trema/executables.rb +26 -2
- data/ruby/trema/features-request.c +3 -5
- data/ruby/trema/flow-removed.c +6 -6
- data/ruby/trema/flow-stats-reply.rb +6 -8
- data/ruby/trema/flow.rb +12 -1
- data/ruby/trema/get-config-request.c +55 -28
- data/ruby/trema/hello.c +3 -5
- data/ruby/trema/host.rb +8 -0
- data/ruby/trema/list-switches-reply.c +1 -1
- data/ruby/trema/mac.rb +1 -1
- data/ruby/trema/match.c +15 -14
- data/ruby/trema/monkey-patch/module/deprecation.rb +0 -2
- data/ruby/trema/netns.rb +127 -0
- data/ruby/trema/ordered-hash.rb +5 -4
- data/ruby/trema/packet-in.c +136 -113
- data/ruby/trema/packet-queue.rb +9 -9
- data/ruby/trema/packetin-filter.rb +1 -1
- data/ruby/trema/phost.rb +16 -7
- data/ruby/trema/port-mod.c +6 -5
- data/ruby/trema/port-stats-reply.rb +2 -2
- data/ruby/trema/process.rb +29 -0
- data/ruby/trema/queue-stats-reply.rb +2 -4
- data/ruby/trema/send-out-port.rb +5 -3
- data/ruby/trema/set-eth-addr.rb +4 -0
- data/ruby/trema/set-ip-addr.rb +4 -2
- data/ruby/trema/set-ip-dst-addr.rb +2 -1
- data/ruby/trema/set-ip-src-addr.rb +2 -1
- data/ruby/trema/set-ip-tos.rb +3 -2
- data/ruby/trema/set-transport-port.rb +3 -2
- data/ruby/trema/set-vlan-priority.rb +3 -2
- data/ruby/trema/set-vlan-vid.rb +5 -4
- data/ruby/trema/shell/reset_stats.rb +2 -1
- data/ruby/trema/shell/run.rb +1 -1
- data/ruby/trema/shell/send_packets.rb +1 -1
- data/ruby/trema/shell/show_stats.rb +1 -1
- data/ruby/trema/stats-helper.rb +3 -3
- data/ruby/trema/stats-reply.c +26 -17
- data/ruby/trema/stats-request.c +39 -41
- data/ruby/trema/switch-daemon.rb +36 -31
- data/ruby/trema/switch.c +1 -1
- data/ruby/trema/table-stats-reply.rb +1 -1
- data/ruby/trema/timers.rb +13 -13
- data/ruby/trema/trema.c +3 -3
- data/ruby/trema/tremashark.rb +9 -2
- data/ruby/trema/util.rb +39 -15
- data/ruby/trema/vendor-action.rb +8 -3
- data/ruby/trema/vendor-stats-reply.rb +4 -6
- data/ruby/trema/vendor.c +1 -1
- data/ruby/trema/version.rb +1 -1
- data/spec/trema/barrier-request_spec.rb +47 -37
- data/spec/trema/controller_spec.rb +1 -0
- data/spec/trema/dsl/runner_spec.rb +8 -3
- data/spec/trema/dsl/vhost_spec.rb +8 -8
- data/spec/trema/echo-request_spec.rb +1 -0
- data/spec/trema/features-request_spec.rb +1 -0
- data/spec/trema/flow-removed_spec.rb +9 -9
- data/spec/trema/get-config-request_spec.rb +51 -39
- data/spec/trema/match_spec.rb +1 -1
- data/spec/trema/openflow-error_spec.rb +11 -11
- data/spec/trema/packet-out_spec.rb +5 -5
- data/spec/trema/queue-get-config-reply_spec.rb +1 -1
- data/spec/trema/queue-get-config-request_spec.rb +1 -1
- data/spec/trema/set-eth-dst-addr_spec.rb +1 -1
- data/spec/trema/set-eth-src-addr_spec.rb +1 -1
- data/spec/trema/set-ip-dst-addr_spec.rb +1 -0
- data/spec/trema/set-ip-src-addr_spec.rb +1 -0
- data/spec/trema/set-ip-tos_spec.rb +1 -0
- data/spec/trema/set-transport-dst-port_spec.rb +1 -0
- data/spec/trema/set-transport-src-port_spec.rb +1 -0
- data/spec/trema/set-vlan-priority_spec.rb +1 -0
- data/spec/trema/set-vlan-vid_spec.rb +2 -1
- data/spec/trema/stats-reply_spec.rb +38 -36
- data/spec/trema/stats-request_spec.rb +6 -6
- data/spec/trema/strip-vlan-header_spec.rb +1 -0
- data/spec/trema/util_spec.rb +3 -2
- data/spec/trema/vendor-action_spec.rb +9 -8
- data/src/examples/dumper/dumper.c +8 -6
- data/src/examples/dumper/dumper.rb +1 -1
- data/{features/step_definitions/killall_steps.rb → src/examples/hello_trema/hello-trema.rb} +6 -5
- data/src/examples/hello_trema/hello_trema.c +4 -4
- data/src/examples/learning_switch/learning_switch.c +1 -1
- data/src/examples/list_switches/list_switches.c +2 -2
- data/src/examples/match_compare/match-compare.rb +2 -2
- data/src/examples/multi_learning_switch/multi-learning-switch.rb +1 -1
- data/src/examples/multi_learning_switch/multi_learning_switch.c +3 -3
- data/src/examples/openflow_message/README +1 -1
- data/src/examples/openflow_message/echo-request.rb +1 -1
- data/src/examples/openflow_message/features_request.c +21 -21
- data/src/examples/openflow_message/hello.c +1 -3
- data/src/examples/openflow_message/hello.rb +9 -24
- data/src/examples/{hello_trema/hello_trema.rb → openflow_message/vendor-action.rb} +17 -7
- data/src/examples/openflow_message/vendor_action.c +105 -0
- data/src/examples/openflow_switch/hello_switch.c +81 -0
- data/src/examples/packet_in/packet-in.rb +9 -13
- data/src/examples/packetin_filter_config/packetin_filter_config.c +2 -2
- data/src/examples/patch_panel/network.conf +14 -0
- data/src/examples/patch_panel/patch-panel.conf +1 -0
- data/{features/step_definitions/show_stats_steps.rb → src/examples/patch_panel/patch-panel.rb} +29 -13
- data/src/examples/switch_info/{switch_info.rb → switch-info.rb} +2 -2
- data/src/examples/switch_info/switch_info.c +4 -4
- data/src/examples/switch_monitor/switch_monitor.c +3 -3
- data/src/examples/traffic_monitor/counter.c +9 -9
- data/src/examples/traffic_monitor/fdb.c +9 -9
- data/src/lib/arp.h +1 -1
- data/src/lib/buffer.c +4 -3
- data/src/lib/byteorder.c +31 -5
- data/src/lib/byteorder.h +2 -2
- data/src/lib/chibach.c +8 -6
- data/src/lib/daemon.c +29 -3
- data/src/lib/doubly_linked_list.c +6 -1
- data/src/lib/ether.c +1 -1
- data/src/lib/ether.h +1 -1
- data/src/lib/event_handler.c +3 -3
- data/src/lib/hash_table.c +1 -1
- data/src/lib/linked_list.c +50 -2
- data/src/lib/linked_list.h +2 -2
- data/src/lib/log.c +122 -22
- data/src/lib/log.h +13 -9
- data/src/lib/management_interface.c +361 -0
- data/src/lib/management_interface.h +42 -0
- data/src/lib/management_service_interface.c +104 -0
- data/src/lib/management_service_interface.h +136 -0
- data/src/lib/match_table.c +5 -5
- data/src/lib/message_queue.c +5 -3
- data/src/lib/message_queue.h +1 -1
- data/src/lib/messenger.c +73 -39
- data/src/lib/messenger.h +3 -2
- data/src/lib/openflow_application_interface.c +17 -17
- data/src/lib/openflow_message.c +175 -23
- data/src/lib/openflow_message.h +2 -1
- data/src/lib/openflow_switch_interface.c +12 -12
- data/src/lib/packet_parser.c +11 -32
- data/src/lib/packetin_filter_interface.c +5 -5
- data/src/lib/persistent_storage.c +7 -7
- data/src/lib/secure_channel.c +6 -6
- data/src/lib/secure_channel.h +1 -1
- data/src/lib/stat.c +54 -17
- data/src/lib/stat.h +9 -0
- data/src/lib/timer.c +11 -10
- data/src/lib/trema.c +38 -9
- data/src/lib/trema.h +1 -0
- data/src/lib/trema_private.h +6 -0
- data/src/lib/trema_wrapper.c +4 -4
- data/src/lib/trema_wrapper.h +10 -10
- data/src/lib/utility.c +6 -6
- data/src/management/application.c +224 -0
- data/src/management/echo.c +185 -0
- data/src/management/set_logging_level.c +153 -0
- data/src/management/show_stats.c +150 -0
- data/src/management/trema_manager +184 -0
- data/src/packetin_filter/packetin_filter.c +31 -29
- data/src/switch_manager/cookie_table.c +7 -7
- data/src/switch_manager/dpid_table.c +3 -3
- data/src/switch_manager/dpid_table.h +0 -1
- data/src/switch_manager/management_interface.h +0 -1
- data/src/switch_manager/ofpmsg_recv.c +3 -3
- data/src/switch_manager/ofpmsg_recv.h +0 -1
- data/src/switch_manager/ofpmsg_send.c +2 -2
- data/src/switch_manager/ofpmsg_send.h +0 -1
- data/src/switch_manager/secure_channel_listener.c +2 -2
- data/src/switch_manager/secure_channel_receiver.c +2 -2
- data/src/switch_manager/secure_channel_receiver.h +0 -1
- data/src/switch_manager/secure_channel_sender.c +8 -1
- data/src/switch_manager/service_interface.c +5 -4
- data/src/switch_manager/switch.c +79 -53
- data/src/switch_manager/switch_manager.c +24 -22
- data/src/switch_manager/xid_table.c +6 -6
- data/src/switch_manager/xid_table.h +0 -1
- data/src/tremashark/README +4 -3
- data/src/tremashark/packet_capture.c +11 -9
- data/src/tremashark/pcap_queue.c +2 -2
- data/src/tremashark/pcap_queue.h +2 -2
- data/src/tremashark/plugin/packet-trema/Makefile +1 -1
- data/src/tremashark/plugin/packet-trema/Makefile.common +1 -1
- data/src/tremashark/plugin/packet-trema/packet-trema.c +50 -37
- data/src/tremashark/queue.c +5 -4
- data/src/tremashark/queue.h +1 -1
- data/src/tremashark/stdin_relay.c +10 -8
- data/src/tremashark/syslog_relay.c +14 -12
- data/src/tremashark/tremashark.c +15 -18
- data/trema +2 -96
- data/trema-config +2 -52
- data/trema.gemspec +12 -1
- data/unittests/cmockery_trema.h +14 -13
- data/unittests/lib/buffer_test.c +1 -1
- data/unittests/lib/byteorder_test.c +108 -25
- data/unittests/lib/daemon_test.c +141 -5
- data/unittests/lib/doubly_linked_list_test.c +5 -1
- data/unittests/lib/ether_test.c +4 -4
- data/unittests/lib/hash_table_test.c +5 -3
- data/unittests/lib/linked_list_test.c +82 -4
- data/unittests/lib/log_test.c +96 -5
- data/unittests/lib/management_interface_test.c +240 -0
- data/unittests/lib/management_service_interface_test.c +319 -0
- data/unittests/lib/message_queue_test.c +6 -2
- data/unittests/lib/messenger_test.c +167 -2
- data/unittests/lib/openflow_application_interface_test.c +16 -22
- data/unittests/lib/openflow_message_test.c +721 -24
- data/unittests/lib/packet_info_test.c +2 -2
- data/unittests/lib/packet_parser_test.c +15 -16
- data/unittests/lib/packetin_filter_interface_test.c +6 -6
- data/unittests/lib/persistent_storage_test.c +11 -11
- data/unittests/lib/stat_test.c +151 -7
- data/unittests/lib/timer_test.c +1 -1
- data/unittests/lib/trema_private_test.c +2 -2
- data/unittests/lib/trema_test.c +40 -12
- data/unittests/lib/utility_test.c +3 -3
- data/unittests/lib/wrapper_test.c +3 -3
- data/unittests/packetin_filter/packetin_filter_test.c +12 -11
- data/unittests/switch_manager/switch_manager_test.c +29 -22
- metadata +99 -20
- data/features/step_definitions/log_steps.rb +0 -90
- data/features/step_definitions/run_steps.rb +0 -91
- data/features/trema.feature +0 -27
- data/features/tutorial.hello_trema.feature +0 -27
- data/features/tutorial.packet_in.feature +0 -47
- data/features/tutorial.switch_info.feature +0 -55
- data/ruby/trema/command/usage.rb +0 -63
|
@@ -93,7 +93,7 @@ int mock_dup2( int oldfd, int newfd );
|
|
|
93
93
|
#undef open
|
|
94
94
|
#endif
|
|
95
95
|
#define open mock_open
|
|
96
|
-
int mock_open(const char *pathname, int flags);
|
|
96
|
+
int mock_open( const char *pathname, int flags );
|
|
97
97
|
|
|
98
98
|
#ifdef execvp
|
|
99
99
|
#undef execvp
|
|
@@ -222,7 +222,7 @@ secure_channel_accept( int fd, void *data ) {
|
|
|
222
222
|
accept_fd = accept( fd, ( struct sockaddr * ) &addr, &addr_len );
|
|
223
223
|
if ( accept_fd < 0 ) {
|
|
224
224
|
// TODO: close listener socket
|
|
225
|
-
error( "Failed to accept from switch. :%s.", strerror( errno )
|
|
225
|
+
error( "Failed to accept from switch. :%s.", strerror( errno ) );
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
228
|
pid = fork();
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
#include "secure_channel_receiver.h"
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
static const size_t RECEIVE_BUFFFER_SIZE = UINT16_MAX + sizeof(struct ofp_packet_in) - 2;
|
|
34
|
+
static const size_t RECEIVE_BUFFFER_SIZE = UINT16_MAX + sizeof( struct ofp_packet_in ) - 2;
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
int
|
|
@@ -80,7 +80,7 @@ recv_from_secure_channel( struct switch_info *sw_info ) {
|
|
|
80
80
|
buffer *message = alloc_buffer_with_length( message_length );
|
|
81
81
|
char *p = append_back_buffer( message, message_length );
|
|
82
82
|
memcpy( p, sw_info->fragment_buf->data, message_length );
|
|
83
|
-
remove_front_buffer( sw_info->fragment_buf, message_length );
|
|
83
|
+
remove_front_buffer( sw_info->fragment_buf, message_length );
|
|
84
84
|
enqueue_message( sw_info->recv_queue, message );
|
|
85
85
|
read_total += message_length;
|
|
86
86
|
}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
#include <assert.h>
|
|
22
22
|
#include <errno.h>
|
|
23
|
+
#include <limits.h>
|
|
23
24
|
#include <openflow.h>
|
|
24
25
|
#include <string.h>
|
|
25
26
|
#include <unistd.h>
|
|
@@ -54,13 +55,19 @@ typedef struct {
|
|
|
54
55
|
} writev_args;
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
static
|
|
58
|
+
static bool
|
|
58
59
|
append_to_writev_args( buffer *message, void *user_data ) {
|
|
59
60
|
writev_args *args = user_data;
|
|
60
61
|
|
|
61
62
|
args->iov[ args->iovcnt ].iov_base = message->data;
|
|
62
63
|
args->iov[ args->iovcnt ].iov_len = message->length;
|
|
63
64
|
args->iovcnt++;
|
|
65
|
+
|
|
66
|
+
if ( args->iovcnt >= IOV_MAX ) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return true;
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
#include <string.h>
|
|
22
21
|
#include <inttypes.h>
|
|
22
|
+
#include <string.h>
|
|
23
23
|
#include "ofpmsg_send.h"
|
|
24
24
|
#include "openflow_service_interface.h"
|
|
25
25
|
#include "service_interface.h"
|
|
@@ -40,7 +40,8 @@ create_openflow_application_message( uint64_t *datapath_id, buffer *data ) {
|
|
|
40
40
|
message = append_back_buffer( buf, sizeof( openflow_service_header_t ) );
|
|
41
41
|
if ( datapath_id == NULL ) {
|
|
42
42
|
message->datapath_id = ~0U; // FIXME: defined invalid datapath_id
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
44
45
|
message->datapath_id = htonll( *datapath_id );
|
|
45
46
|
}
|
|
46
47
|
message->service_name_length = htons( 0 );
|
|
@@ -85,7 +86,7 @@ service_send_to_application( list_element *service_name_list, uint16_t message_t
|
|
|
85
86
|
static const char *error_service_name = NULL;
|
|
86
87
|
for ( list = service_name_list; list != NULL; list = list->next ) {
|
|
87
88
|
service_name = list->data;
|
|
88
|
-
if ( !send_message( service_name, message_type,
|
|
89
|
+
if ( !send_message( service_name, message_type,
|
|
89
90
|
buf->data, buf->length ) ) {
|
|
90
91
|
if ( error_service_name != service_name ) {
|
|
91
92
|
warn( "Failed to send message ( service_name = %s ).", service_name );
|
|
@@ -133,7 +134,7 @@ service_recv_from_application( uint16_t message_type, buffer *buf ) {
|
|
|
133
134
|
char *service_name;
|
|
134
135
|
|
|
135
136
|
if ( buf->length < sizeof( openflow_service_header_t ) + sizeof( struct ofp_header ) ) {
|
|
136
|
-
error( "Too short openflow application message(%
|
|
137
|
+
error( "Too short openflow application message(%zu).", buf->length );
|
|
137
138
|
free_buffer( buf );
|
|
138
139
|
|
|
139
140
|
return;
|
data/src/switch_manager/switch.c
CHANGED
|
@@ -73,9 +73,11 @@ static char short_options[] = "s:";
|
|
|
73
73
|
|
|
74
74
|
struct switch_info switch_info;
|
|
75
75
|
|
|
76
|
-
static const time_t COOKIE_TABLE_AGING_INTERVAL = 3600;
|
|
77
|
-
static const time_t ECHO_REQUEST_INTERVAL = 60;
|
|
78
|
-
static const time_t ECHO_REPLY_TIMEOUT = 2;
|
|
76
|
+
static const time_t COOKIE_TABLE_AGING_INTERVAL = 3600; // sec.
|
|
77
|
+
static const time_t ECHO_REQUEST_INTERVAL = 60; // sec.
|
|
78
|
+
static const time_t ECHO_REPLY_TIMEOUT = 2; // ses.
|
|
79
|
+
static const time_t WARNING_ECHO_RTT = 500; // msec. The value must is less than 1000.
|
|
80
|
+
|
|
79
81
|
|
|
80
82
|
static bool age_cookie_table_enabled = false;
|
|
81
83
|
|
|
@@ -91,24 +93,26 @@ usage() {
|
|
|
91
93
|
"OpenFlow Switch Manager.\n"
|
|
92
94
|
"Usage: %s [OPTION]... [DESTINATION-RULE]...\n"
|
|
93
95
|
"\n"
|
|
94
|
-
" -s, --socket=fd
|
|
95
|
-
" -n, --name=SERVICE_NAME
|
|
96
|
-
" -l, --logging_level=LEVEL
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
" --no-
|
|
100
|
-
"
|
|
96
|
+
" -s, --socket=fd secure channnel socket\n"
|
|
97
|
+
" -n, --name=SERVICE_NAME service name\n"
|
|
98
|
+
" -l, --logging_level=LEVEL set logging level\n"
|
|
99
|
+
" -g, --syslog output log messages to syslog\n"
|
|
100
|
+
" -f, --logging_facility=FACILITY set syslog facility\n"
|
|
101
|
+
" --no-flow-cleanup do not cleanup flows on startup\n"
|
|
102
|
+
" --no-cookie-translation do not translate cookie values\n"
|
|
103
|
+
" --no-packet_in do not allow packet-ins on startup\n"
|
|
104
|
+
" -h, --help display this help and exit\n"
|
|
101
105
|
"\n"
|
|
102
106
|
"DESTINATION-RULE:\n"
|
|
103
107
|
" openflow-message-type::destination-service-name\n"
|
|
104
108
|
"\n"
|
|
105
109
|
"openflow-message-type:\n"
|
|
106
|
-
" packet_in
|
|
107
|
-
" port_status
|
|
108
|
-
" vendor
|
|
109
|
-
" state_notify
|
|
110
|
+
" packet_in packet-in openflow message type\n"
|
|
111
|
+
" port_status port-status openflow message type\n"
|
|
112
|
+
" vendor vendor openflow message type\n"
|
|
113
|
+
" state_notify connection status\n"
|
|
110
114
|
"\n"
|
|
111
|
-
"destination-service-name
|
|
115
|
+
"destination-service-name destination service name\n"
|
|
112
116
|
, get_executable_name()
|
|
113
117
|
);
|
|
114
118
|
}
|
|
@@ -184,7 +188,7 @@ service_send_state( struct switch_info *sw_info, uint64_t *dpid, uint16_t tag )
|
|
|
184
188
|
|
|
185
189
|
|
|
186
190
|
static void
|
|
187
|
-
secure_channel_read( int fd, void*
|
|
191
|
+
secure_channel_read( int fd, void *data ) {
|
|
188
192
|
UNUSED( fd );
|
|
189
193
|
UNUSED( data );
|
|
190
194
|
|
|
@@ -204,7 +208,7 @@ secure_channel_read( int fd, void* data ) {
|
|
|
204
208
|
|
|
205
209
|
|
|
206
210
|
static void
|
|
207
|
-
secure_channel_write( int fd, void*
|
|
211
|
+
secure_channel_write( int fd, void *data ) {
|
|
208
212
|
UNUSED( fd );
|
|
209
213
|
UNUSED( data );
|
|
210
214
|
|
|
@@ -346,7 +350,10 @@ switch_event_recv_echoreply( struct switch_info *sw_info, buffer *buf ) {
|
|
|
346
350
|
|
|
347
351
|
SUB_TIMESPEC( &now, &tim, &tim );
|
|
348
352
|
|
|
349
|
-
|
|
353
|
+
if ( tim.tv_sec > 0 || tim.tv_nsec > ( ( long ) WARNING_ECHO_RTT * 1000000 ) ) {
|
|
354
|
+
warn( "echo round-trip time is greater then %ld ms ( round-trip time = %" PRId64 ".%09ld ).",
|
|
355
|
+
( long ) WARNING_ECHO_RTT, ( int64_t ) tim.tv_sec, tim.tv_nsec );
|
|
356
|
+
}
|
|
350
357
|
|
|
351
358
|
return 0;
|
|
352
359
|
}
|
|
@@ -404,6 +411,13 @@ switch_event_recv_featuresreply( struct switch_info *sw_info, uint64_t *dpid ) {
|
|
|
404
411
|
// rename service_name of messenger
|
|
405
412
|
rename_message_received_callback( get_trema_name(), new_service_name );
|
|
406
413
|
|
|
414
|
+
// rename management service name
|
|
415
|
+
char *management_service_name = xstrdup( get_management_service_name( get_trema_name() ) );
|
|
416
|
+
char *new_management_service_name = xstrdup( get_management_service_name( new_service_name ) );
|
|
417
|
+
rename_message_requested_callback( management_service_name, new_management_service_name );
|
|
418
|
+
xfree( management_service_name );
|
|
419
|
+
xfree( new_management_service_name );
|
|
420
|
+
|
|
407
421
|
debug( "Rename service name from %s to %s.", get_trema_name(), new_service_name );
|
|
408
422
|
if ( messenger_dump_enabled() ) {
|
|
409
423
|
stop_messenger_dump();
|
|
@@ -528,39 +542,56 @@ switch_event_recv_error( struct switch_info *sw_info ) {
|
|
|
528
542
|
|
|
529
543
|
|
|
530
544
|
static void
|
|
531
|
-
management_recv(
|
|
545
|
+
management_recv( const messenger_context_handle *handle, uint32_t command, void *data, size_t data_len, void *user_data ) {
|
|
532
546
|
UNUSED( data );
|
|
533
547
|
UNUSED( data_len );
|
|
548
|
+
UNUSED( user_data );
|
|
534
549
|
|
|
535
|
-
switch (
|
|
536
|
-
|
|
537
|
-
|
|
550
|
+
switch ( command ) {
|
|
551
|
+
case DUMP_XID_TABLE:
|
|
552
|
+
{
|
|
553
|
+
dump_xid_table();
|
|
554
|
+
}
|
|
538
555
|
break;
|
|
539
556
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
557
|
+
case DUMP_COOKIE_TABLE:
|
|
558
|
+
{
|
|
559
|
+
if ( !switch_info.cookie_translation ) {
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
dump_cookie_table();
|
|
543
563
|
}
|
|
544
|
-
dump_cookie_table();
|
|
545
564
|
break;
|
|
546
565
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
566
|
+
case TOGGLE_COOKIE_AGING:
|
|
567
|
+
{
|
|
568
|
+
if ( !switch_info.cookie_translation ) {
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
if ( age_cookie_table_enabled ) {
|
|
572
|
+
delete_timer_event( age_cookie_table, NULL );
|
|
573
|
+
age_cookie_table_enabled = false;
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
add_periodic_event_callback( COOKIE_TABLE_AGING_INTERVAL, age_cookie_table, NULL );
|
|
577
|
+
age_cookie_table_enabled = true;
|
|
578
|
+
}
|
|
558
579
|
}
|
|
559
580
|
break;
|
|
560
581
|
|
|
561
|
-
|
|
562
|
-
|
|
582
|
+
default:
|
|
583
|
+
{
|
|
584
|
+
error( "Undefined management command ( %#x )", command );
|
|
585
|
+
management_application_reply *reply = create_management_application_reply( MANAGEMENT_REQUEST_FAILED, command, NULL, 0 );
|
|
586
|
+
send_management_application_reply( handle, reply );
|
|
587
|
+
xfree( reply );
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
563
590
|
}
|
|
591
|
+
|
|
592
|
+
management_application_reply *reply = create_management_application_reply( MANAGEMENT_REQUEST_SUCCEEDED, command, NULL, 0 );
|
|
593
|
+
send_management_application_reply( handle, reply );
|
|
594
|
+
xfree( reply );
|
|
564
595
|
}
|
|
565
596
|
|
|
566
597
|
|
|
@@ -585,7 +616,6 @@ main( int argc, char *argv[] ) {
|
|
|
585
616
|
int ret;
|
|
586
617
|
int i;
|
|
587
618
|
char *service_name;
|
|
588
|
-
char management_service_name[ MESSENGER_SERVICE_NAME_LENGTH ];
|
|
589
619
|
|
|
590
620
|
init_trema( &argc, &argv );
|
|
591
621
|
option_parser( argc, argv );
|
|
@@ -601,20 +631,20 @@ main( int argc, char *argv[] ) {
|
|
|
601
631
|
#define PORTSTATUS_PREFIX "port_status::"
|
|
602
632
|
#define STATE_PREFIX "state_notify::"
|
|
603
633
|
for ( i = optind; i < argc; i++ ) {
|
|
604
|
-
if ( strncmp( argv[i], VENDER_PREFIX, strlen( VENDER_PREFIX ) ) == 0 ) {
|
|
605
|
-
service_name = xstrdup( argv[i] + strlen( VENDER_PREFIX ) );
|
|
634
|
+
if ( strncmp( argv[ i ], VENDER_PREFIX, strlen( VENDER_PREFIX ) ) == 0 ) {
|
|
635
|
+
service_name = xstrdup( argv[ i ] + strlen( VENDER_PREFIX ) );
|
|
606
636
|
insert_in_front( &switch_info.vendor_service_name_list, service_name );
|
|
607
637
|
}
|
|
608
|
-
else if ( strncmp( argv[i], PACKET_IN_PREFIX, strlen( PACKET_IN_PREFIX ) ) == 0 ) {
|
|
609
|
-
service_name = xstrdup( argv[i] + strlen( PACKET_IN_PREFIX ) );
|
|
638
|
+
else if ( strncmp( argv[ i ], PACKET_IN_PREFIX, strlen( PACKET_IN_PREFIX ) ) == 0 ) {
|
|
639
|
+
service_name = xstrdup( argv[ i ] + strlen( PACKET_IN_PREFIX ) );
|
|
610
640
|
insert_in_front( &switch_info.packetin_service_name_list, service_name );
|
|
611
641
|
}
|
|
612
|
-
else if ( strncmp( argv[i], PORTSTATUS_PREFIX, strlen( PORTSTATUS_PREFIX ) ) == 0 ) {
|
|
613
|
-
service_name = xstrdup( argv[i] + strlen( PORTSTATUS_PREFIX ) );
|
|
642
|
+
else if ( strncmp( argv[ i ], PORTSTATUS_PREFIX, strlen( PORTSTATUS_PREFIX ) ) == 0 ) {
|
|
643
|
+
service_name = xstrdup( argv[ i ] + strlen( PORTSTATUS_PREFIX ) );
|
|
614
644
|
insert_in_front( &switch_info.portstatus_service_name_list, service_name );
|
|
615
645
|
}
|
|
616
|
-
else if ( strncmp( argv[i], STATE_PREFIX, strlen( STATE_PREFIX ) ) == 0 ) {
|
|
617
|
-
service_name = xstrdup( argv[i] + strlen( STATE_PREFIX ) );
|
|
646
|
+
else if ( strncmp( argv[ i ], STATE_PREFIX, strlen( STATE_PREFIX ) ) == 0 ) {
|
|
647
|
+
service_name = xstrdup( argv[ i ] + strlen( STATE_PREFIX ) );
|
|
618
648
|
insert_in_front( &switch_info.state_service_name_list, service_name );
|
|
619
649
|
}
|
|
620
650
|
}
|
|
@@ -647,11 +677,7 @@ main( int argc, char *argv[] ) {
|
|
|
647
677
|
}
|
|
648
678
|
|
|
649
679
|
add_message_received_callback( get_trema_name(), service_recv );
|
|
650
|
-
|
|
651
|
-
snprintf( management_service_name , MESSENGER_SERVICE_NAME_LENGTH,
|
|
652
|
-
"%s.m", get_trema_name() );
|
|
653
|
-
management_service_name[ MESSENGER_SERVICE_NAME_LENGTH - 1 ] = '\0';
|
|
654
|
-
add_message_received_callback( management_service_name, management_recv );
|
|
680
|
+
set_management_application_request_handler( management_recv, NULL );
|
|
655
681
|
|
|
656
682
|
ret = switch_event_connected( &switch_info );
|
|
657
683
|
if ( ret < 0 ) {
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
#include <limits.h>
|
|
22
21
|
#include <errno.h>
|
|
23
22
|
#include <getopt.h>
|
|
24
23
|
#include <inttypes.h>
|
|
24
|
+
#include <limits.h>
|
|
25
|
+
#include <openflow.h>
|
|
26
|
+
#include <signal.h>
|
|
25
27
|
#include <stdio.h>
|
|
26
28
|
#include <stdlib.h>
|
|
27
|
-
#include <signal.h>
|
|
28
29
|
#include <string.h>
|
|
29
|
-
#include <unistd.h>
|
|
30
30
|
#include <sys/wait.h>
|
|
31
|
-
#include <
|
|
31
|
+
#include <unistd.h>
|
|
32
32
|
#include "trema.h"
|
|
33
33
|
#include "secure_channel_listener.h"
|
|
34
34
|
#include "switch_manager.h"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
#undef printf
|
|
45
45
|
#endif
|
|
46
46
|
#define printf( fmt, args... ) mock_printf2( fmt, ##args )
|
|
47
|
-
int mock_printf2(const char *format, ...);
|
|
47
|
+
int mock_printf2( const char *format, ... );
|
|
48
48
|
|
|
49
49
|
#ifdef die
|
|
50
50
|
#undef die
|
|
@@ -76,7 +76,7 @@ void mock_secure_channel_accept( struct listener_info *listener_info );
|
|
|
76
76
|
#undef access
|
|
77
77
|
#endif
|
|
78
78
|
#define access mock_access
|
|
79
|
-
int mock_access( const char *pathname, int mode);
|
|
79
|
+
int mock_access( const char *pathname, int mode );
|
|
80
80
|
|
|
81
81
|
#ifdef get_current_dir_name
|
|
82
82
|
#undef get_current_dir_name
|
|
@@ -136,7 +136,7 @@ const char *mock_get_executable_name( void );
|
|
|
136
136
|
#undef set_external_callback
|
|
137
137
|
#endif
|
|
138
138
|
#define set_external_callback mock_set_external_callback
|
|
139
|
-
void mock_set_external_callback( void ( *callback )
|
|
139
|
+
void mock_set_external_callback( void ( *callback )( void ) );
|
|
140
140
|
|
|
141
141
|
#endif // UNIT_TESTING
|
|
142
142
|
|
|
@@ -156,17 +156,19 @@ static char short_options[] = "p:s:";
|
|
|
156
156
|
void
|
|
157
157
|
usage() {
|
|
158
158
|
printf(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
159
|
+
"OpenFlow Switch Manager.\n"
|
|
160
|
+
"Usage: %s [OPTION]... [-- SWITCH_MANAGER_OPTION]...\n"
|
|
161
|
+
"\n"
|
|
162
|
+
" -s, --switch=PATH the command path of switch\n"
|
|
163
|
+
" -n, --name=SERVICE_NAME service name\n"
|
|
164
|
+
" -p, --port=PORT server listen port (default %u)\n"
|
|
165
|
+
" -d, --daemonize run in the background\n"
|
|
166
|
+
" -l, --logging_level=LEVEL set logging level\n"
|
|
167
|
+
" -g, --syslog output log messages to syslog\n"
|
|
168
|
+
" -f, --logging_facility=FACILITY set syslog facility\n"
|
|
169
|
+
" -h, --help display this help and exit\n"
|
|
170
|
+
, get_executable_name(), OFP_TCP_PORT
|
|
171
|
+
);
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
|
|
@@ -257,9 +259,9 @@ init_listener_info( struct listener_info *listener_info ) {
|
|
|
257
259
|
|
|
258
260
|
|
|
259
261
|
static void
|
|
260
|
-
finalize_listener_info(
|
|
262
|
+
finalize_listener_info( struct listener_info *listener_info ) {
|
|
261
263
|
if ( listener_info->switch_daemon != NULL ) {
|
|
262
|
-
xfree( (void *)( uintptr_t )listener_info->switch_daemon );
|
|
264
|
+
xfree( ( void * ) ( uintptr_t ) listener_info->switch_daemon );
|
|
263
265
|
listener_info->switch_daemon = NULL;
|
|
264
266
|
}
|
|
265
267
|
if ( listener_info->listen_fd >= 0 ) {
|
|
@@ -299,7 +301,7 @@ parse_argument( struct listener_info *listener_info, int argc, char *argv[] ) {
|
|
|
299
301
|
}
|
|
300
302
|
break;
|
|
301
303
|
case 's':
|
|
302
|
-
xfree( (void *)( uintptr_t )listener_info->switch_daemon );
|
|
304
|
+
xfree( ( void * ) ( uintptr_t ) listener_info->switch_daemon );
|
|
303
305
|
listener_info->switch_daemon = xstrdup( optarg );
|
|
304
306
|
break;
|
|
305
307
|
default:
|
|
@@ -413,7 +415,7 @@ main( int argc, char *argv[] ) {
|
|
|
413
415
|
|
|
414
416
|
switch_daemon = listener_info.switch_daemon;
|
|
415
417
|
listener_info.switch_daemon = absolute_path( startup_dir, switch_daemon );
|
|
416
|
-
xfree( ( void * )( uintptr_t )switch_daemon );
|
|
418
|
+
xfree( ( void * ) ( uintptr_t ) switch_daemon );
|
|
417
419
|
// free returned buffer of get_current_dir_name()
|
|
418
420
|
free( startup_dir );
|
|
419
421
|
|
|
@@ -64,7 +64,7 @@ static xid_entry_t *
|
|
|
64
64
|
allocate_xid_entry( uint32_t original_xid, char *service_name, int index ) {
|
|
65
65
|
xid_entry_t *new_entry;
|
|
66
66
|
|
|
67
|
-
new_entry = xmalloc( sizeof
|
|
67
|
+
new_entry = xmalloc( sizeof( xid_entry_t ) );
|
|
68
68
|
new_entry->xid = generate_xid();
|
|
69
69
|
new_entry->original_xid = original_xid;
|
|
70
70
|
new_entry->service_name = xstrdup( service_name );
|
|
@@ -91,7 +91,7 @@ init_xid_table( void ) {
|
|
|
91
91
|
|
|
92
92
|
void
|
|
93
93
|
finalize_xid_table( void ) {
|
|
94
|
-
for( int i = 0; i < XID_MAX_ENTRIES; i++ ) {
|
|
94
|
+
for ( int i = 0; i < XID_MAX_ENTRIES; i++ ) {
|
|
95
95
|
if ( xid_table.entries[ i ] != NULL ) {
|
|
96
96
|
free_xid_entry( xid_table.entries[ i ] );
|
|
97
97
|
xid_table.entries[ i ] = NULL;
|
|
@@ -107,7 +107,7 @@ uint32_t
|
|
|
107
107
|
insert_xid_entry( uint32_t original_xid, char *service_name ) {
|
|
108
108
|
xid_entry_t *new_entry;
|
|
109
109
|
|
|
110
|
-
debug( "Inserting xid entry ( original_xid = %#
|
|
110
|
+
debug( "Inserting xid entry ( original_xid = %#" PRIx32 ", service_name = %s ).",
|
|
111
111
|
original_xid, service_name );
|
|
112
112
|
|
|
113
113
|
if ( xid_table.next_index >= XID_MAX_ENTRIES ) {
|
|
@@ -133,13 +133,13 @@ insert_xid_entry( uint32_t original_xid, char *service_name ) {
|
|
|
133
133
|
|
|
134
134
|
void
|
|
135
135
|
delete_xid_entry( xid_entry_t *delete_entry ) {
|
|
136
|
-
debug( "Deleting xid entry ( xid = %#
|
|
136
|
+
debug( "Deleting xid entry ( xid = %#" PRIx32 ", original_xid = %#" PRIx32 ", service_name = %s, index = %d ).",
|
|
137
137
|
delete_entry->xid, delete_entry->original_xid, delete_entry->service_name, delete_entry->index );
|
|
138
138
|
|
|
139
139
|
xid_entry_t *deleted = delete_hash_entry( xid_table.hash, &delete_entry->xid );
|
|
140
140
|
|
|
141
141
|
if ( deleted == NULL ) {
|
|
142
|
-
error( "Failed to delete xid entry ( xid = %#
|
|
142
|
+
error( "Failed to delete xid entry ( xid = %#" PRIx32 " ).", delete_entry->xid );
|
|
143
143
|
free_xid_entry( ( xid_entry_t * ) delete_entry );
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
@@ -157,7 +157,7 @@ lookup_xid_entry( uint32_t xid ) {
|
|
|
157
157
|
|
|
158
158
|
static void
|
|
159
159
|
dump_xid_entry( xid_entry_t *entry ) {
|
|
160
|
-
info( "xid = %#
|
|
160
|
+
info( "xid = %#" PRIx32 ", original_xid = %#" PRIx32 ", service_name = %s, index = %d",
|
|
161
161
|
entry->xid, entry->original_xid, entry->service_name, entry->index );
|
|
162
162
|
}
|
|
163
163
|
|