Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trema::Match*_mask does not work #48

Closed
sugyo opened this issue Jun 7, 2013 · 6 comments
Closed

Trema::Match*_mask does not work #48

sugyo opened this issue Jun 7, 2013 · 6 comments

Comments

@sugyo
Copy link
Member

sugyo commented Jun 7, 2013

Trema::Match*_mask does not work

@yasuhito
Copy link
Member

すみません、具体的にどういう問題が出るか、もしあればペーストしてもらえますか? trema-dev か Twitter で同じ問題を見たような。。?

@sugyo
Copy link
Member Author

sugyo commented Jun 19, 2013

下記のtwitterです。trema-edgeには、定義はあるけど、未実装?

trema-edge(ruby)のMatch.newでipv6_dst_maskに何を書いても反映されてない風味。。どう書くのが正解なのだろう。

— Kenji Ohira (@torus77) June 4, 2013
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

sugyo pushed a commit that referenced this issue Jun 26, 2013
- update r_match_to_oxm_match()
- add pbb_isid_mask into Trema::Match
@sugyo
Copy link
Member Author

sugyo commented Jun 26, 2013

修正した。issues #12 で見直してください

@sugyo sugyo closed this as completed Jun 26, 2013
@rakshasa
Copy link
Contributor

"#<TypeError: can't convert IPAddr into Integer>"
"/opt/.../trema-abb78667c386/ruby/trema/message.rb:39:in `pack_flow_mod_msg'"
...

The change broke ipv4_dst/src, likely since they used 'nw_addr_to_i' not 'NUM2UINT'.

@sugyo
Copy link
Member Author

sugyo commented Jun 26, 2013

thanks.
If you're hurry, Please try the following patches:

--- a/ruby/trema/conversion-util.c
+++ b/ruby/trema/conversion-util.c
@@ -177,6 +177,19 @@ ofp_match_to_r_match( const struct ofp_match *match ) {
   } \
 }

+#define APPEND_OXM_MATCH_IPV4_ADDR_MASK( r_match, at_value, append_oxm_match_f, match ) \
+{ \
+  VALUE r_value = rb_iv_get( r_match, at_value ); \
+  if ( !NIL_P( r_value ) ) { \
+    uint32_t mask = 0; \
+    VALUE r_mask = rb_iv_get( r_match, at_value "_mask" ); \
+    if ( !NIL_P( r_mask ) ) { \
+      mask = nw_addr_to_i( r_mask ); \
+    } \
+    append_oxm_match_f( match, nw_addr_to_i( r_value ), mask ); \
+  } \
+}
+
 #define APPEND_OXM_MATCH_IPV6_ADDR( r_match, at_value, append_oxm_match_f, match ) \
 { \
   VALUE r_value = rb_iv_get( r_match, at_value ); \
@@ -218,8 +231,8 @@ r_match_to_oxm_match( VALUE r_match, oxm_matches *match ) {
   APPEND_OXM_MATCH_UINT8( r_match, "@ip_ecn", append_oxm_match_ip_ecn, match );
   APPEND_OXM_MATCH_UINT8( r_match, "@ip_proto", append_oxm_match_ip_proto, match );

-  APPEND_OXM_MATCH_UINT32_MASK( r_match, "@ipv4_src", append_oxm_match_ipv4_src, match );
-  APPEND_OXM_MATCH_UINT32_MASK( r_match, "@ipv4_dst", append_oxm_match_ipv4_dst, match );
+  APPEND_OXM_MATCH_IPV4_ADDR_MASK( r_match, "@ipv4_src", append_oxm_match_ipv4_src, match );
+  APPEND_OXM_MATCH_IPV4_ADDR_MASK( r_match, "@ipv4_dst", append_oxm_match_ipv4_dst, match );

   APPEND_OXM_MATCH_UINT16( r_match, "@tcp_src", append_oxm_match_tcp_src, match );
   APPEND_OXM_MATCH_UINT16( r_match, "@tcp_dst", append_oxm_match_tcp_dst, match );

@sugyo sugyo reopened this Jun 26, 2013
@rakshasa
Copy link
Contributor

#50

This fixes it for both ipv4_* and arp_*.

@sugyo sugyo closed this as completed Jul 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants